Re: How to determine if date/time is with DST or not ?

From: Date: Sun, 15 Aug 2004 07:13:51 +0000
Subject: Re: How to determine if date/time is with DST or not ?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-193868@lists.php.net to get a copy of this message
"-{ Rene Brehmer }-" <metalbunny@metalbunny.net> wrote in message news:vb3th01ju7vndovbtc37iqm58vflvlsnhn@4ax.com... > 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/ Hi Rene, I'm not totally sure but I loosely remember this topic being discussed here some weeks ago. Try your look by searching the mailing list archives. Best regards, Torsten Roehr

« previous php.general (#193868) next »