Re: handling dates before 1901

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I don't know why it would have been working before and now stopped, but take a 
look at the DateTime class in PHP 5.2.  It is designed to use 64-bit dates 
internally so it should handle a larger date range than humans have existed 
for.  It has both OOP and procedural routines, depending on your preference.

http://www.php.net/manual/en/function.date-create.php

On Thursday 28 February 2008, Gabriel Kuri wrote:
> I recently migrated some php scripts from a box running php 4.4.4 to php
> 5.2.5. due to the nature of the data, some of the php scripts require
> handling dates before 1901. both boxes are 64-bit (original and new),
> however the new box isn't handling dates properly before 1901 with
> either the mktime() or strtotime() functions. it was working perfectly
> on the old box and I'm stumped as to why it stopped working on the new
> one. did the mktime() and strtotime() functions in php 5 regress to
> handling the dates as 32-bit ints?
>
> here's an example of some php code to test between the two boxes:
>
> <?php
>
> echo "12-13-1901: ".mktime(0,0,0, 12, 13, 1901)."\n";
> echo "12-14-1901: ".mktime(0,0,0, 12, 14, 1901)."\n";
>
> echo "1-18-2038: ".mktime(0,0,0, 1, 18, 2038)."\n";
> echo "1-19-2038: ".mktime(0,0,0, 1, 19, 2038)."\n";
>
> echo "12-13-1901: ".strtotime("12/13/1901")."\n";
> echo "12-14-1901: ".strtotime("12/14/1901")."\n";
>
> ?>
>
>
> output of code on old box:
>
> 	12-13-1901: -2147529600
> 	12-14-1901: -2147443200
> 	1-18-2038: 2147414400
> 	1-19-2038: 2147500800
> 	12-13-1901: -2147529600
> 	12-14-1901: -2147443200
>
> output of code on new box:
>
> 	12-13-1901:
> 	12-14-1901: -2147443200
> 	1-18-2038: 2147414400
> 	1-19-2038:
> 	12-13-1901:
> 	12-14-1901: -2147443200
>
> thanks much ...
>
>
> -----
> Gabriel Kuri | Sr. Network Engineer
> Instructional and Information Technology Division
> California State Polytechnic University, Pomona
> http://www.csupomona.edu/~iit | +1 909 979 6363


-- 
Larry Garfield			AIM: LOLG42
larry@xxxxxxxxxxxxxxxx		ICQ: 6817012

"If nature has made any one thing less susceptible than all others of 
exclusive property, it is the action of the thinking power called an idea, 
which an individual may exclusively possess as long as he keeps it to 
himself; but the moment it is divulged, it forces itself into the possession 
of every one, and the receiver cannot dispossess himself of it."  -- Thomas 
Jefferson

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux