fork download
  1. <?php
  2.  
  3. $dt_1 = new DateTime('01.02.2014', new DateTimeZone('Europe/Moscow'));
  4. $dt_2 = new DateTime('01.03.2014', new DateTimeZone('Europe/Moscow'));
  5.  
  6. $diff = $dt_1->diff($dt_2);
  7. var_dump($diff->format('%m'));
  8. var_dump($diff->m);
  9. var_dump($diff->d);
  10.  
  11. $dt_1 = new DateTime('01.02.2014', new DateTimeZone('UTC'));
  12. $dt_2 = new DateTime('01.03.2014', new DateTimeZone('UTC'));
  13.  
  14. $diff = $dt_1->diff($dt_2);
  15. var_dump($diff->format('%m'));
  16. var_dump($diff->m);
  17. var_dump($diff->d);
Success #stdin #stdout 0.01s 20520KB
stdin
Standard input is empty
stdout
string(1) "0"
int(0)
int(28)
string(1) "1"
int(1)
int(0)