PHP script to show when a store is open -


i'm trying build php script when store opened show words "is open" , when it's closed it'll show "is closed" based on timezone , hours. can't seem work, found script doesn't work properly.. should work on dutch timezone.. +1 amsterdam.. can aid me?

i'd appreciate help!

script:

<?php $schedule[0] = "700-1730"; $schedule[1] = "700-1730"; $schedule[2] = "700-1730"; $schedule[3] = "700-1730"; $schedule[4] = "10:00-17:30";  $schedule[5] = "700-1300"; $schedule[6] = "0";  $today = $schedule[date('w')];  list($open, $close) = explode('-', $schedule);  $now = (int) date('gi');  $state = 'is geopend.';  if ($today[0] == 0 || $now < (int) $today[0] || $now > (int) $today[1]) {   $state = 'is gesloten.'; } ?> <?php echo $state;?> 

the colon causing bit of problem can remove quick str_replace();

instead of $schedule want explode(); $today once have made it.

<?php $schedule[0] = "700-1730"; $schedule[1] = "700-1730"; $schedule[2] = "700-1730"; $schedule[3] = "700-1730"; $schedule[4] = "10:00-17:30"; $schedule[5] = "700-1300"; $schedule[6] = "0";  $today = $schedule[date('w')]; $now = (int) date('gi');  list($open, $close) = explode('-', $today); // rid of colon if have used 1 $open = (int) str_replace(':', '', $open); $close = (int) str_replace(':', '', $close);   $state = ' geopend.'; if ($today[0] == 0 || $now < $open || $now > $close){   $state = ' gesloten.'; } ?> 

depending on setup of server, if don't want dynamically reset timezone in ini settings, add 100 per hour want adjust by, if have hours time difference in database make variable $time_difference * 100 , add or subtract $now = (int) date('gi'); so, example $now = (int) date('gi') + 700; give european central time when server time based on new york time or $now = (int) date('gi') + $time_difference * 100; used adjust dynamically. (you need account daylight saving time though!)

time reference right way set timezones: php date(); timezone?

in case wanted play using user's own timezone display opening times , adjust accordingly bit of fun - may not advisable live project there seem few totally reliable ways. determine user's timezone

please note numbers days work 0 sunday 6 saturday http://php.net/manual/en/function.date.php


Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -