3v4l.org

run code in 500+ PHP versions simultaneously
<?php // Fake data $data = [ ['start' => '2022-11-03'], ['start' => '2022-11-04'], ['start' => date('Y-m-d')], ]; $now = new DateTime(); foreach($data as $records) { $start = new DateTime($records['start']); $diff = $start->diff(new DateTime()); // Convert days and hours to minutes, and sum them all up to get total // diff in minutes $minutes = ($diff->days * 24 * 60) + ($diff->h * 60) + ($diff->i); echo $start->format('Y-m-d H:i') . " was " . $minutes . " minutes ago\n"; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 12, Position 2 = 42
Branch analysis from position: 12
2 jumps found. (Code = 78) Position 1 = 13, Position 2 = 42
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
Branch analysis from position: 42
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 42
filename:       /in/JeDuE
function name:  (null)
number of ops:  44
compiled vars:  !0 = $data, !1 = $now, !2 = $records, !3 = $start, !4 = $diff, !5 = $minutes
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    5     0  E >   INIT_ARRAY                                           ~6      <array>
          1        ADD_ARRAY_ELEMENT                                    ~6      <array>
    7     2        INIT_FCALL                                                   'date'
          3        SEND_VAL                                                     'Y-m-d'
          4        DO_ICALL                                             $7      
          5        INIT_ARRAY                                           ~8      $7, 'start'
          6        ADD_ARRAY_ELEMENT                                    ~6      ~8
    4     7        ASSIGN                                                       !0, ~6
   10     8        NEW                                                  $10     'DateTime'
          9        DO_FCALL                                          0          
         10        ASSIGN                                                       !1, $10
   12    11      > FE_RESET_R                                           $13     !0, ->42
         12    > > FE_FETCH_R                                                   $13, !2, ->42
   13    13    >   NEW                                                  $14     'DateTime'
         14        CHECK_FUNC_ARG                                               
         15        FETCH_DIM_FUNC_ARG                                   $15     !2, 'start'
         16        SEND_FUNC_ARG                                                $15
         17        DO_FCALL                                          0          
         18        ASSIGN                                                       !3, $14
   14    19        INIT_METHOD_CALL                                             !3, 'diff'
         20        NEW                                                  $18     'DateTime'
         21        DO_FCALL                                          0          
         22        SEND_VAR_NO_REF_EX                                           $18
         23        DO_FCALL                                          0  $20     
         24        ASSIGN                                                       !4, $20
   18    25        FETCH_OBJ_R                                          ~22     !4, 'days'
         26        MUL                                                  ~23     ~22, 24
         27        MUL                                                  ~24     ~23, 60
         28        FETCH_OBJ_R                                          ~25     !4, 'h'
         29        MUL                                                  ~26     ~25, 60
         30        ADD                                                  ~27     ~24, ~26
         31        FETCH_OBJ_R                                          ~28     !4, 'i'
         32        ADD                                                  ~29     ~27, ~28
         33        ASSIGN                                                       !5, ~29
   19    34        INIT_METHOD_CALL                                             !3, 'format'
         35        SEND_VAL_EX                                                  'Y-m-d+H%3Ai'
         36        DO_FCALL                                          0  $31     
         37        CONCAT                                               ~32     $31, '+was+'
         38        CONCAT                                               ~33     ~32, !5
         39        CONCAT                                               ~34     ~33, '+minutes+ago%0A'
         40        ECHO                                                         ~34
   12    41      > JMP                                                          ->12
         42    >   FE_FREE                                                      $13
   20    43      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
188.71 ms | 1472 KiB | 14 Q