Hi,
Does anyone know of any good replacements for time(), date() and mktime() that can handle dates beyond the year 2038?
Thanks
Code to replace time(), date() and mktime() beyond 2038?
Moderator: General Moderators
Re: Code to replace time(), date() and mktime() beyond 2038?
Why doesn't date() work beyond 2038?foobaa wrote:Hi,
Does anyone know of any good replacements for time(), date() and mktime() that can handle dates beyond the year 2038?
Thanks
Code: Select all
mike@mike-kubuntu:~$ php -q test.php
Sep 04, 2109
mike@mike-kubuntu:~$ cat test.php
<?php
print date("M d, Y", strtotime("+100 years")) . "\n";
?>
mike@mike-kubuntu:~$
Re: Code to replace time(), date() and mktime() beyond 2038?
I tried inputting date('jmY', 2678227200) and it returned 1901 where as it should be 2054. I'm using PHP5.3 on Ubuntu 8.
I've just found this:
http://phplens.com/phpeverywhere/adodb_date_library
Which extends all of PHP's related functions.
Cheers
I've just found this:
http://phplens.com/phpeverywhere/adodb_date_library
Which extends all of PHP's related functions.
Cheers
-
Mark Baker
- Forum Regular
- Posts: 710
- Joined: Thu Oct 30, 2008 6:24 pm
Re: Code to replace time(), date() and mktime() beyond 2038?
foobaa wrote:I tried inputting date('jmY', 2678227200) and it returned 1901 where as it should be 2054. I'm using PHP5.3 on Ubuntu 8.
I've just found this:
http://phplens.com/phpeverywhere/adodb_date_library
Which extends all of PHP's related functions.
Cheers
Code: Select all
mike@mike-kubuntu:~$ php -a
Interactive shell
php > print date("m/d/Y", 2678227200);
11/13/2054
php >
PHP 5.2.6-3ubuntu4.1 with Suhosin-Patch 0.9.6.2 (cli) (built: Apr 23 2009 14:37:14)
Copyright (c) 1997-2008 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies
mike@mike-kubuntu:~$
-
Mark Baker
- Forum Regular
- Posts: 710
- Joined: Thu Oct 30, 2008 6:24 pm
Re: Code to replace time(), date() and mktime() beyond 2038?
Depends whether you're running on a 32-bit or a 64-bit platform.Mirge wrote:Why doesn't date() work beyond 2038?
Re: Code to replace time(), date() and mktime() beyond 2038?
Ahh you're right. I ran it on a 32-bit platform (same snippet I pasted above) and it returned 1918 for the year.Mark Baker wrote:Depends whether you're running on a 32-bit or a 64-bit platform.Mirge wrote:Why doesn't date() work beyond 2038?