RE: [PHP] GMT strtotime() problem today!!
| From: | Ford, Mike [LSS] | Date: | Tue, 01 Apr 2003 10:40:24 +0000 |
| Subject: | RE: [PHP] GMT strtotime() problem today!! | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-141796@lists.php.net to get a copy of this message | ||
> -----Original Message-----
> From: Stuart Cochrane [mailto:php@php-editors.com]
> Sent: 31 March 2003 15:45
>
> I have a script that runs on over 250 Servers, all are running NT4.
> here is the script:
>
> [php]
> function last_sunday() {
> return gmdate("Y-m-d", strtotime("Last Sunday"));
> }
> echo "Last Sunday is returned as: ".last_sunday();
> [/php]
>
> Some servers have 'automatically adjust clock for daylight saving
> changes' switched on, some have this off - (im in the UK GMT +0).
>
> With daylight saving on the above script returns: 2003-03-29
> With daylight saving off the above script returns: 2003-03-30
>
> Im puzzled with this one - any ideas?
Well, since this is clearly a DST problem, I'd adopt the classic
DST-avoiding solution and specify a *time* that won't cause date-shifts if
it gets DST adjusted. Also, as you're using gmdate, I think I'd specify
that in strtotime() too. Taken together, this would give you something
like:
return gmdate("Y-m-d", strtotime("Last Sunday 12:00 GMT"));
Cheers!
Mike
---------------------------------------------------------------------
Mike Ford, Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS, LS6 3QS, United Kingdom
Email: m.ford@lmu.ac.uk
Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211