3v4l.org

run code in 300+ PHP versions simultaneously
<?php $currentDate = date("Y-m-d"); $currentTime = date("H:i:s"); $row2['post_date'] = "2013-12-02 10:00:00"; $currentDateHour = date("H", strtotime($currentDate . " " . $currentTime)); // This is the date I'm pulling from the database, it only displays // when in strtotime for some reason. It displays accurately to what is in the mySQL DB $upDate = date("Y-m-d H", strtotime($row2['post_date'])); // Some variables to make life easier for later if statements if I ever get that far. Displays accurately. $upDatehour = date("H", strtotime($row2['post_date'])); // trying simple subtraction $hour = $currentDateHour - $upDatehour; // this is where the result is incorrect, what is wrong here? Any method I've tried gives me the same result, with or without strotime.. it's gotta be something simple, always is! print $hour;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VADPF
function name:  (null)
number of ops:  42
compiled vars:  !0 = $currentDate, !1 = $currentTime, !2 = $row2, !3 = $currentDateHour, !4 = $upDate, !5 = $upDatehour, !6 = $hour
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   INIT_FCALL                                               'date'
          1        SEND_VAL                                                 'Y-m-d'
          2        DO_ICALL                                         $7      
          3        ASSIGN                                                   !0, $7
    3     4        INIT_FCALL                                               'date'
          5        SEND_VAL                                                 'H%3Ai%3As'
          6        DO_ICALL                                         $9      
          7        ASSIGN                                                   !1, $9
    5     8        ASSIGN_DIM                                               !2, 'post_date'
          9        OP_DATA                                                  '2013-12-02+10%3A00%3A00'
    7    10        INIT_FCALL                                               'date'
         11        SEND_VAL                                                 'H'
         12        INIT_FCALL                                               'strtotime'
         13        CONCAT                                           ~12     !0, '+'
         14        CONCAT                                           ~13     ~12, !1
         15        SEND_VAL                                                 ~13
         16        DO_ICALL                                         $14     
         17        SEND_VAR                                                 $14
         18        DO_ICALL                                         $15     
         19        ASSIGN                                                   !3, $15
   11    20        INIT_FCALL                                               'date'
         21        SEND_VAL                                                 'Y-m-d+H'
         22        INIT_FCALL                                               'strtotime'
         23        FETCH_DIM_R                                      ~17     !2, 'post_date'
         24        SEND_VAL                                                 ~17
         25        DO_ICALL                                         $18     
         26        SEND_VAR                                                 $18
         27        DO_ICALL                                         $19     
         28        ASSIGN                                                   !4, $19
   15    29        INIT_FCALL                                               'date'
         30        SEND_VAL                                                 'H'
         31        INIT_FCALL                                               'strtotime'
         32        FETCH_DIM_R                                      ~21     !2, 'post_date'
         33        SEND_VAL                                                 ~21
         34        DO_ICALL                                         $22     
         35        SEND_VAR                                                 $22
         36        DO_ICALL                                         $23     
         37        ASSIGN                                                   !5, $23
   18    38        SUB                                              ~25     !3, !5
         39        ASSIGN                                                   !6, ~25
   21    40        ECHO                                                     !6
         41      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
159.18 ms | 1396 KiB | 17 Q