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 }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 22
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
filename:       /in/QNHsE
function name:  (null)
number of ops:  23
compiled vars:  !0 = $date, !1 = $info, !2 = $date_to_sec_1, !3 = $date_to_sec_2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'date'
          1        SEND_VAL                                                 'Y-m-d+H%3Ai%3As'
          2        DO_ICALL                                         $4      
          3        ASSIGN                                                   !0, $4
    6     4        ASSIGN_DIM                                               !1, 'lastboot'
          5        OP_DATA                                                  '2014-04-27+01%3A55%3A55'
   14     6        INIT_FCALL                                               'strtotime'
          7        SEND_VAR                                                 !0
          8        DO_ICALL                                         $7      
          9        ASSIGN                                                   !2, $7
   15    10        INIT_FCALL                                               'strtotime'
         11        FETCH_DIM_R                                      ~9      !1, 'lastboot'
         12        SEND_VAL                                                 ~9
         13        DO_ICALL                                         $10     
         14        ASSIGN                                                   !3, $10
   17    15        IS_SMALLER                                               !3, !2
         16      > JMPZ                                                     ~12, ->22
   19    17    >   SUB                                              ~13     !2, !3
         18        CONCAT                                           ~14     'You+need+to+wait+for+', ~13
         19        CONCAT                                           ~15     ~14, '+seconds+before+next+boot'
         20        ECHO                                                     ~15
         21      > JMP                                                      ->22
   24    22    > > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.1 ms | 1387 KiB | 17 Q