Check out the manual:
http://www.php.net/strtotime

Theoretically, this should work:
$old_date = strtotime("January 1, 1903 18:11 pm");
echo date("Y-m-d H:i:s", $old_date);

But all that echoes is:
1969-12-31 18:59:59

On that manual page, you'll see the following note:

<quote>
Note: The valid range of a timestamp is typically from Fri, 13 Dec 1901 20:45:54 GMT to Tue, 19 Jan 2038 03:14:07 GMT. (These are the dates that correspond to the minimum and maximum values for a 32-bit signed integer.) Additionally, not all platforms support negative timestamps, therefore your date range may be limited to no earlier than the Unix epoch. This means that e.g. dates prior to Jan 1, 1970 will not work on Windows, some Linux distributions, and a few other operating systems.
</quote>


I'm not sure whether there is a good work-around for converting that string to a timestamp; however, this does work and will produce the desired results:

$old_date = mktime(0, 11, 18, 1, 1, 1903);
echo date("Y-m-d H:i:s", $old_date);


Adwinwijaya wrote:


Hello php-general,

  how to display date like Monday, 1 January 1903 18:11 pm in php ?
  (since the date() function only able to display date before 1970)
  (and why it only support date after 1 Jan 1970) ?
  thanks


-- Regards, Ben Ramsey http://benramsey.com http://www.phpcommunity.org/wiki/People/BenRamsey

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to