Re: how to convert a string into a date format ?????

From: Date: Sat, 13 Oct 2001 15:40:43 +0000
Subject: Re: how to convert a string into a date format ?????
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-70991@lists.php.net to get a copy of this message
On Wed, 10 Oct 2001 09:01:26 +0000 (GMT) impersonator of philip@cornado.com (Philip Olson) planted &I saw in php.general: >> Keep in mind, however, that a unix_timestamp has a range starting at Jan 1, >> 1970. If you are working only with current dates, then this will not be a >> problem, but if you are working with historical dates, such as a persons >> age, then do not go with the unix_timestamp. > >They end up being negative. For example : > > $date_str = '1943-10-25'; > print strtotime($date_str); // -826416000 > >Will work with date() too. Good to know that, if it is indeed true. But erroneous date format data gives -1 by strtotime() and that produces error on date() function, which contradicts your finding, unless -1 is a specialy treated data. But according to your logic it should represent something like 31 Dec 1969 23-59-59 :) (I'll double check later, when i come to it) But yes, this is definitely something to >consider when dealing with unix timestamps. The limitations afaik are as >follows : > > -2147483647 // December 13, 1901 > 2147483647 // January 19, 2038 > > http://pasadena.wr.usgs.gov/office/given/timekeeping.html > >I'm not much of an authority but point is, negatives work too :) > >regards, >Philip Olson > > >> At 06:50 AM 10/10/2001 +0000, Philip Olson wrote: >> >Also consider the strtotime() function, it'll give you the unix timestamp >> >of this string. Example : >> > >> > $date_str = '2001-10-25'; >> > >> > print strtotime($date_str); // 1003968000 >> > >> >Using it with date() can be like : >> > >> > print date('F d, Y',strtotime($date_str)); // October 25, 2001 >> > See above for $date_str = -1 (Why only they didn't make errors -> false != -1

« previous php.general (#70991) next »