php - DateTime Class not support the years before 1960? -


i have following situation:

$birth = new datetime('1960'); echo $birth->diff( new datetime() )->format('%y'); 

the output 56 - ok, when set argument 1959 or less value got result 0. example:

$birth = new datetime('1959'); echo $birth->diff( new datetime() )->format('%y'); 

the output 0.

the test environment is:

  • php 5.5.9-1ubuntu4.17
  • apache/2.4.10 (ubuntu)

thanks!

you need specify valid datetime input new datetime().

i guess 1960 can interpreted year, while 1959 time. printing out difference in years between time , time @ 19:59 0.

you better off specifying full date, 1959-01-01.


Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -