So i have this code to determine difference between present time and datetime field value from database.
This code gives weird output (samples below) for dates that are not in same year.
$deadline = new DateTime($someDeadline, new DateTimeZone('CET'));
$time_now = new DateTime('NOW', new DateTimeZone('CET'));
$overdue_until = $time_now->diff($deadline);
echo $overdue_until->format('%R %d day/s, %h hours, %i minutes');
Example results:
Monday 9th of February 2015 05:28:23 PM gets the difference + 28 day/s, 17 hours, 6 minutes from current time.
Wednesday 14th of January 2015 11:28:43 AM + 2 day/s, 10 hours, 34 minutes
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.