Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Output:
- ======
- Test... int(0) 0 0 0 0 9 0
- 9
- Test Code:
- ======
- Test...
- <?php
- error_reporting(E_ALL);
- ini_set("display_errors", 1);
- $total = 0;
- $january = new DateTime('2010-01-01 00:00:01');
- $february = new DateTime('2010-01-01 00:09:01');
- $interval = $february->diff($january);
- $year = $interval->format('%y');
- $month = $interval->format('%m');
- $days = $interval->format('%a');
- $hours = $interval->format('%h');
- $minutes = $interval->format('%i');
- $seconds = (int) $interval->format('%s'); var_dump($seconds); // int(0) $interval->s;
- $total += ($seconds >0 ) ? 1 : 0;
- $total += ($minutes >0 ) ? $minutes : 0;
- $total += ($hours >0 ) ? ($hours * 60) : 0;
- $total += ($days >0 ) ? (($days * 24) * 60) : 0;
- echo $year . ' ' . $month . ' ' . $days . ' ' . $hours . ' ' . $minutes . ' ' . $seconds . '<br/>';
- echo $total;
- ?>
Add Comment
Please, Sign In to add comment