1

I have an issue with PHP function mktime when trying to get unix_timestamps bigger that for year 2038. I have 64-bit OS.

PHP version on server: php -v gives PHP 5.1.6 (cli) (built: Nov 29 2010 16:47:46)

php -r 'echo PHP_INT_MAX;' gives 9223372036854775807

but

php -r 'var_dump( mktime(0, 0, 0, 4, 1, 2099) );' gives bool(false)

On development server php -r 'var_dump( mktime(0, 0, 0, 4, 1, 2099) );' gives int(4078677600)

What may be the cause for this PHP function not to work properly on 64-bit system? Also strtotime does not work with dates where year is greater than 2038

2
  • Try to use DateTime class. Commented Aug 12, 2014 at 15:19
  • DateTime class is only available since (PHP 5 >= 5.2.0). As this point I have PHP 5.1.6 Upgrading is an option, but that's one of the last ones. Commented Aug 12, 2014 at 15:25

1 Answer 1

0

http://en.wikipedia.org/wiki/Year_2038_problem

Who do you call? "Captain Hindsight!"

On a more serious note, for large date ranges I would use the traditional DB datetime storage method of YYYY-MM-DD HH:MM:SS. It is easily parsed and highly portable.

Using DateTime for runtime usage is most feasible, the latter string pattern for persistence.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.