3v4l.org

run code in 300+ PHP versions simultaneously
<?php $date = date("Y-m-d H:i:s"); // current time; viz since I'm in India, it'll set Current Indian Time i.e. 2014-04-28 02:31:58 (exactly like this) $info['lastboot'] = "2014-04-27 01:55:55"; // I'm assuming this as your last boot time stored in your DB //Now to compare both the time value, convert them to exact seconds using PHP buit-in function `strtotime()` //What strtotime() does is convert the string date viz. 2014-04-28 02:31:58 into seconds. //These seconds are counted from the UNIX EPOCH i.e since 01 Jan 1970 00:00:00 $date_to_sec_1 = strtotime($date); $date_to_sec_2 = strtotime($info['lastboot']); if($date_to_sec_1 > $date_to_sec_2) { echo "You need to wait for ".($date_to_sec_1-$date_to_sec_2)." seconds before next boot"; } else { // else part }
Output for 5.3.0 - 5.3.12, 5.3.15 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.17, 7.0.19 - 7.0.33, 7.1.0 - 7.1.27, 7.1.29 - 7.1.33, 7.2.0 - 7.2.16, 7.2.18 - 7.2.33, 7.3.0 - 7.3.2, 7.3.5 - 7.3.31, 7.4.0 - 7.4.33, 8.0.0 - 8.0.12, 8.0.14 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
You need to wait for 76652 seconds before next boot
Output for 7.3.32 - 7.3.33, 8.0.13
You need to wait for 69452 seconds before next boot
Output for 5.3.13 - 5.3.14, 7.0.18, 7.1.28, 7.2.17, 7.3.3 - 7.3.4
You need to wait for 76653 seconds before next boot
Output for 4.3.0 - 4.3.11, 4.4.0 - 4.4.9, 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17
You need to wait for 76413 seconds before next boot

preferences:
296.79 ms | 402 KiB | 460 Q