hi gang I'm trying to find a simple way to determine if a given date/time is with DST for a given locale at any point in time ... the point is basically to convert date strings into accurate GMT timestamps for storage in the database...
Like I've got date strings looking like: Thursday, July 22, 2004 8:50:01 PM July 22, 2004 6:42 PM the strings are submitted through a form, together with a variable determining the time zone these times are in. I just want to figure out if the dates are with or without dst for that locale, at that given time, so that I can properly convert them to GMT times ... but I have no clue how to do that ... haven't been able to find anything useful in the manual or the PHP Cookbook ... the time zone is submitted negative of the actual value ... so a time offset of -0700 is submitted as +7 and +0200 as -2 ... this is simply to make the time conversion simpler... these are extracts of the current time calculation codes, including some debugging code for the time conversion: <?php $date = $_POST['date']; $tzone = $_POST['tzone']; $timestamp = strtotime($date); if ($tzone != 'none') { $tdif = $tzone.' hours'; $timestamp = strtotime($tdif,$timestamp); } ?> /* the following part is an extra of a larger table ... the formatting of the time zone is merely for displaying purposes atm. The goal is to create RFC2822 dates to be stored in the database alongside messages... */ <td>Workdate: <?php echo($date.' '.$tzone); ?><br> Time difference: <?php if ($tzone > 0) { $format = '-'; } else { $format = '+'; } if (abs($tzone) > 9) { $format .= '%u00'; } else { $format .= '0%u00'; } printf($format,abs($tzone)); ?><br> Unix timestamp: <?php echo($timestamp); ?><br> GMT date: <?php echo(date('D, d M Y H:i:s',$timestamp)); ?></td> if anyone has any ideas for determining whether DST is on or off, I'd appreciate it. right now I have no clue how to do this the easiest... TIA Rene -- Rene Brehmer aka Metalbunny If your life was a dream, would you wake up from a nightmare, dripping of sweat, hoping it was over? Or would you wake up happy and pleased, ready to take on the day with a smile? http://metalbunny.net/ References, tools, and other useful stuff... Check out the new Metalbunny forums at http://forums.metalbunny.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php