3v4l.org

run code in 300+ PHP versions simultaneously
<?php function dateDifference($date_1, $date_2, $differenceFormat = '%a') // %a { if (is_numeric($date_1)) $datetime1 = (new DateTime())->setTimeStamp($date_1/1000); else $datetime1 = new DateTime($date_1); $datetime2 = (new DateTime())->setTimeStamp($date_2/1000); $interval = $datetime1->diff($datetime2); return $interval->format($differenceFormat) * 8.64e+7; } echo dateDifference('2019-02-05T11:51:20', 1551791511000) . PHP_EOL; echo dateDifference(time()*1000, 1551791511000) . PHP_EOL;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YPKSi
function name:  (null)
number of ops:  16
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   INIT_FCALL                                               'datedifference'
          1        SEND_VAL                                                 '2019-02-05T11%3A51%3A20'
          2        SEND_VAL                                                 1551791511000
          3        DO_FCALL                                      0  $0      
          4        CONCAT                                           ~1      $0, '%0A'
          5        ECHO                                                     ~1
   15     6        INIT_FCALL                                               'datedifference'
          7        INIT_FCALL                                               'time'
          8        DO_ICALL                                         $2      
          9        MUL                                              ~3      $2, 1000
         10        SEND_VAL                                                 ~3
         11        SEND_VAL                                                 1551791511000
         12        DO_FCALL                                      0  $4      
         13        CONCAT                                           ~5      $4, '%0A'
         14        ECHO                                                     ~5
   16    15      > RETURN                                                   1

Function datedifference:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 15
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YPKSi
function name:  dateDifference
number of ops:  36
compiled vars:  !0 = $date_1, !1 = $date_2, !2 = $differenceFormat, !3 = $datetime1, !4 = $datetime2, !5 = $interval
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV_INIT                                        !2      '%25a'
    5     3        INIT_FCALL                                               'is_numeric'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $6      
          6      > JMPZ                                                     $6, ->15
    6     7    >   NEW                                              $7      'DateTime'
          8        DO_FCALL                                      0          
          9        INIT_METHOD_CALL                                         $7, 'setTimeStamp'
         10        DIV                                              ~9      !0, 1000
         11        SEND_VAL_EX                                              ~9
         12        DO_FCALL                                      0  $10     
         13        ASSIGN                                                   !3, $10
    5    14      > JMP                                                      ->19
    8    15    >   NEW                                              $12     'DateTime'
         16        SEND_VAR_EX                                              !0
         17        DO_FCALL                                      0          
         18        ASSIGN                                                   !3, $12
    9    19    >   NEW                                              $15     'DateTime'
         20        DO_FCALL                                      0          
         21        INIT_METHOD_CALL                                         $15, 'setTimeStamp'
         22        DIV                                              ~17     !1, 1000
         23        SEND_VAL_EX                                              ~17
         24        DO_FCALL                                      0  $18     
         25        ASSIGN                                                   !4, $18
   10    26        INIT_METHOD_CALL                                         !3, 'diff'
         27        SEND_VAR_EX                                              !4
         28        DO_FCALL                                      0  $20     
         29        ASSIGN                                                   !5, $20
   11    30        INIT_METHOD_CALL                                         !5, 'format'
         31        SEND_VAR_EX                                              !2
         32        DO_FCALL                                      0  $22     
         33        MUL                                              ~23     $22, 8.64e+7
         34      > RETURN                                                   ~23
   12    35*     > RETURN                                                   null

End of function datedifference

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
136.67 ms | 1006 KiB | 17 Q