hi. i'm storing events in a mysql-db, using epoch timestamps to pinpoint the exact date/time for an event. so far, I have been using localtime, being aware that there are inconsistencies in the number of epoch-seconds, when DST flips on and off. nevertheless, that works fine as long as you stick to mktime() and date() for all the date-math as in mktime(0,0,0,$month,$day+$offset,$year) but as soon as you leave php and have to do some calculation in javascript, you will encounter functions that behave differently on the pc and mac platforms. so you have to revert back to the 'add 86400-seconds' to calculate the next day. so I thought it would be nice to have all the timestamps as linear, non-dst-epoch-seconds (UTC) and I went into the gmmktime() and gmdate() functions, assuming they would do the math in a linear second-based timespace (in GMT, without DST). That seems to be the case for the output of 'gmdate', that remains correct, if you count up seconds across the DST boundary (see second example). but it seems that there is no way to calculate the gmt-epoch for a given date using gmmktime without having to add/subtract the TZ manually. gmmktime will always take your local DST-settings into calculation and upon conversion back with gmdate, you will be off by the number of hours of your timezone. I thought gmmktime() would handle this as if the computer would be in Greenwich (TZ=0), which would then leave us with the two functions encoding/decoding consistently. anyone having solved this properly? ------------------------------------- print "count days:<br>\n"; for($day=0; $day<7; $day++){ $timgmt = gmmktime(0,0,0,3,28+$day,2002); $timloc = mktime(0,0,0,3,28+$day,2002); print $timgmt . "= gmmktim epoch - " . gmdate("D d.m.Y H:i I",$timgmt) . "<br>\n"; print $timloc . "= mktim epoch - " . date("D d.m.Y H:i I",$timloc) . "<br>\n"; print "<BR>\n"; } ---- count days: 1017270000= gmmktim epoch - Wed 27.03.2002 23:00 0 1017270000= mktim epoch - Thu 28.03.2002 00:00 0 1017356400= gmmktim epoch - Thu 28.03.2002 23:00 0 1017356400= mktim epoch - Fri 29.03.2002 00:00 0 1017442800= gmmktim epoch - Fri 29.03.2002 23:00 0 1017442800= mktim epoch - Sat 30.03.2002 00:00 0 1017529200= gmmktim epoch - Sat 30.03.2002 23:00 0 1017529200= mktim epoch - Sun 31.03.2002 00:00 0 <<<dst on 1017619200= gmmktim epoch - Mon 01.04.2002 00:00 0 <<< off by one hour due to DST 1017612000= mktim epoch - Mon 01.04.2002 00:00 1 1017705600= gmmktim epoch - Tue 02.04.2002 00:00 0 1017698400= mktim epoch - Tue 02.04.2002 00:00 1 1017792000= gmmktim epoch - Wed 03.04.2002 00:00 0 1017784800= mktim epoch - Wed 03.04.2002 00:00 1 ------------------------------------- print "count seconds:<br>\n"; $baseepoch = $timloc = mktime(0,0,0,3,28,2002); for($day=0; $day<7; $day++){ $epochnow = $baseepoch + (60 * 60 * 24 * $day); print $epochnow . "= gmmktim epoch - " . gmdate("D d.m.Y H:i I",$epochnow) . "<br>\n"; print $epochnow . "= mktim epoch - " . date("D d.m.Y H:i I",$epochnow) . "<br>\n"; print "<BR>\n"; } ---- count seconds: 1017270000= gmmktim epoch - Wed 27.03.2002 23:00 0 <<< consistent, but off by -1 (your TZ) 1017270000= mktim epoch - Thu 28.03.2002 00:00 0 1017356400= gmmktim epoch - Thu 28.03.2002 23:00 0 1017356400= mktim epoch - Fri 29.03.2002 00:00 0 1017442800= gmmktim epoch - Fri 29.03.2002 23:00 0 1017442800= mktim epoch - Sat 30.03.2002 00:00 0 1017529200= gmmktim epoch - Sat 30.03.2002 23:00 0 1017529200= mktim epoch - Sun 31.03.2002 00:00 0 1017615600= gmmktim epoch - Sun 31.03.2002 23:00 0 1017615600= mktim epoch - Mon 01.04.2002 01:00 1 1017702000= gmmktim epoch - Mon 01.04.2002 23:00 0 1017702000= mktim epoch - Tue 02.04.2002 01:00 1 1017788400= gmmktim epoch - Tue 02.04.2002 23:00 0 1017788400= mktim epoch - Wed 03.04.2002 01:00 1 -- PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php