datetime - php 32bit date parsing for dates before 13Dec 1901 -


i happily using strtotime() on development machine parse dates of in 1800s, extreme example in 1500s.

but development machine 64 bit , server 32 bit. on 32 bit machine date before fri, 13 dec 1901 20:45:54 utc out of range (see notes on strtotime).

i happy write custom code this, thought ask if of php inbuilt functions manage this. dates in iso 8601 format.

for worth server centos 5.4 php 5.2.10

1901-12-12t05:00:00z example

i can't test right now, datetime's constructor may able accept format without needing createfromformat. can't tell documentation.

try

try {     $date = new datetime('1901-12-12t05:00:00z'); } catch (exception $e) {     echo "arggh! ".$e->getmessage();     die(); }  echo $date->format('y-m-d h:i:s'); 

and see happens, paying special attention whether understands z (i.e. makes utc time).

datetime uses 64 bit numbers internally on system, , has no range limitations.

as said, 5.3 on, able use createfromformat can parse date expressed 1 of date()'s placeholders. optimal way, because force parse specific pattern, instead of guessing it.


Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -