7

Will the php function time(); be functional after the year 2038?

dynamic
  • 46,985
  • 55
  • 154
  • 231

2 Answers2

9

Of course, when the time comes PHP 42.1.3 will natively support 64-bit integers.

Alix Axel
  • 151,645
  • 95
  • 393
  • 500
0

Yes, it should be. But let me run that code in my VirtuaBox and changed the date as well in there.

you know it could be fun to try it out :)

fedmich
  • 5,343
  • 3
  • 37
  • 52
  • 1
    You'll probably get a signed (negative) integer. Let me know how it goes! ;) – Alix Axel Apr 28 '11 at 23:31
  • also I'm imagining that by that time, there will be a better language, new language or it might not be even called PHP anymore – fedmich Apr 28 '11 at 23:32
  • 2
    What happened, did the world change? – edgarmtze Apr 28 '11 at 23:32
  • @fedmich: No, RoR will be gone and PHP will still rule the world! NURV! :P – Alix Axel Apr 28 '11 at 23:34
  • @fedmich If PHP's name changes, it'll probably change to "PHP", where the first P stands for "PHP", [of which the first P stands for "PHP"](http://en.wikipedia.org/wiki/Recursive_acronym). Infinite recursion will crash the Internet. – Wiseguy Apr 28 '11 at 23:37
  • Wait a moment. I Don't think you have to run a virtualbox to change the date in your os – dynamic Apr 28 '11 at 23:43
  • 4
    I just execute it and I got -2138856280 ... looks like our apps will break then :( – fedmich Apr 28 '11 at 23:48
  • @yes123 I couldnt change the date of my computer/server as there's too many apps going on and processing some stuff; so I could only execute codes like this via virtuabox. – fedmich Apr 28 '11 at 23:50
  • Lol... all I could say is that PHP Rocks! – fedmich Apr 28 '11 at 23:59
  • You can fake the system time using [libfaketime](http://www.code-wizards.com/projects/libfaketime/index.html). On Linux x86_64 with PHP 5.4.13, the value returned is not negative. `LD_PRELOAD=src/libfaketime.so.1 FAKETIME="31337-12-12 00:00:00" php -r 'echo time(),"\n";'` gives `48541007779`. Oh, but `date` seems to have issues interpreting `31337` though (`3508-03-16`). On the lucky side, `4242` works! – Lekensteyn Mar 23 '13 at 22:05