Re: strtotime - assumptions about default formatting of dates

From: Date: Thu, 24 Dec 2009 13:51:56 +0000
Subject: Re: strtotime - assumptions about default formatting of dates
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-300671@lists.php.net to get a copy of this message
On Thu, Dec 24, 2009 at 13:20, Angus Mann <angusmann@pobox.com> wrote: > Hi all. I need to allow users to enter dates and times, and for a while now I've been > forcing them to use javascript date/time pickers so I can be absolutely sure the formatting is > correct. > > Some users are requesting to be able to type the entries themselves so I've decided to > allow this. > > I'm in Australia, and the standard formatting of dates here is DD/MM/YYYY or DD-MM-YYYY > > I recognize this is different to what seems to happen in the US, where it is MM/DD/YYYY or > MM-DD-YYYY > > When I process an entered date using strtotime() it seems to work fine. > > But of course I am concerned when dates like January 2 come up. > > I find that 2/1/2009 is interpreted as January 2, 2009 on my installation, which is Windows 7 > with location set to Australia. > > But can I be sure that all installations of PHP, perhaps in different countries and on > different operating systems will interpret dates the same? > > I can't find much mention of this question online or in the manual. > > Any help much appreciated. > Angus > strtotime() interprets dates according to the rules of the current timezone. The specific rules are outlined in GNU's manual: http://www.gnu.org/software/tar/manual/html_node/Date-input-formats.html -- Daniel Egeberg

« previous php.general (#300671) next »