Guest User

Untitled

a guest
Jan 21st, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. <?php
  2.  
  3. /*
  4. * Very simple way to get the number of seconds from Jan 1, 0001 or any other date
  5. * the normal date/time functions only work from 1 Jan 1970
  6. * Requires PHP 5.3 or above
  7. * Start: must be in YYYY-MM-DD format
  8. * End: must be in YYYY-MM-DD format
  9. */
  10.  
  11. function seconds_since($start='0001-01-01',$end=date(Y-m-d))
  12. (
  13.  
  14. $datetime1 = new DateTime($start);
  15. $datetime2 = new DateTime($end);
  16. $interval = $datetime1->diff($datetime2);
  17.  
  18. return $interval->format('%a') * 24 * 60 * 60;
  19. }
  20.  
  21. ?>
Add Comment
Please, Sign In to add comment