3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Query timestamp of entry //returns like this $entrydatetime = "2013-11-20 17:36:18"; //get current time $now = new \DateTime(); // Use DateTime on $entrydatetime $entrydatetime = new \DateTime($entrydatetime); // Seconds echo $now->getTimestamp() - $entrydatetime->getTimestamp() . "seconds\n"; // Human readable is more complex $age = $now->diff($entrydatetime); // DateInterval if ($age->y > 0) { echo $age->format('%y years ago'); } else if ($age->m > 0) { echo $age->format('%m months ago'); } else if ($age->days > 0) { echo $age->format('%a days ago'); } else { echo $age->format('%h hours, %i minutes ago'); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 22, Position 2 = 27
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 47
Branch analysis from position: 47
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 27
2 jumps found. (Code = 43) Position 1 = 30, Position 2 = 35
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 47
Branch analysis from position: 47
Branch analysis from position: 35
2 jumps found. (Code = 43) Position 1 = 38, Position 2 = 43
Branch analysis from position: 38
1 jumps found. (Code = 42) Position 1 = 47
Branch analysis from position: 47
Branch analysis from position: 43
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/1QgAq
function name:  (null)
number of ops:  48
compiled vars:  !0 = $entrydatetime, !1 = $now, !2 = $age
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   ASSIGN                                                   !0, '2013-11-20+17%3A36%3A18'
   10     1        NEW                                              $4      'DateTime'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $4
   13     4        NEW                                              $7      'DateTime'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0          
          7        ASSIGN                                                   !0, $7
   17     8        INIT_METHOD_CALL                                         !1, 'getTimestamp'
          9        DO_FCALL                                      0  $10     
         10        INIT_METHOD_CALL                                         !0, 'getTimestamp'
         11        DO_FCALL                                      0  $11     
         12        SUB                                              ~12     $10, $11
         13        CONCAT                                           ~13     ~12, 'seconds%0A'
         14        ECHO                                                     ~13
   21    15        INIT_METHOD_CALL                                         !1, 'diff'
         16        SEND_VAR_EX                                              !0
         17        DO_FCALL                                      0  $14     
         18        ASSIGN                                                   !2, $14
   24    19        FETCH_OBJ_R                                      ~16     !2, 'y'
         20        IS_SMALLER                                               0, ~16
         21      > JMPZ                                                     ~17, ->27
   25    22    >   INIT_METHOD_CALL                                         !2, 'format'
         23        SEND_VAL_EX                                              '%25y+years+ago'
         24        DO_FCALL                                      0  $18     
         25        ECHO                                                     $18
         26      > JMP                                                      ->47
   26    27    >   FETCH_OBJ_R                                      ~19     !2, 'm'
         28        IS_SMALLER                                               0, ~19
         29      > JMPZ                                                     ~20, ->35
   27    30    >   INIT_METHOD_CALL                                         !2, 'format'
         31        SEND_VAL_EX                                              '%25m+months+ago'
         32        DO_FCALL                                      0  $21     
         33        ECHO                                                     $21
         34      > JMP                                                      ->47
   28    35    >   FETCH_OBJ_R                                      ~22     !2, 'days'
         36        IS_SMALLER                                               0, ~22
         37      > JMPZ                                                     ~23, ->43
   29    38    >   INIT_METHOD_CALL                                         !2, 'format'
         39        SEND_VAL_EX                                              '%25a+days+ago'
         40        DO_FCALL                                      0  $24     
         41        ECHO                                                     $24
         42      > JMP                                                      ->47
   31    43    >   INIT_METHOD_CALL                                         !2, 'format'
         44        SEND_VAL_EX                                              '%25h+hours%2C+%25i+minutes+ago'
         45        DO_FCALL                                      0  $25     
         46        ECHO                                                     $25
   32    47    > > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.71 ms | 1390 KiB | 13 Q