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-28 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 }

preferences:
42.5 ms | 402 KiB | 5 Q