3v4l.org

run code in 300+ PHP versions simultaneously
<?php function s_datediff( $str_interval, $dt_menor, $dt_maior, $relative=false){ if( is_string( $dt_menor)) $dt_menor = date_create( $dt_menor); if( is_string( $dt_maior)) $dt_maior = date_create( $dt_maior); $diff = date_diff( $dt_menor, $dt_maior, ! $relative); switch( $str_interval){ case "y": $total = $diff->y + $diff->m / 12 + $diff->d / 365.25; break; case "m": $total= $diff->y * 12 + $diff->m + $diff->d/30 + $diff->h / 24; break; case "d": $total = $diff->y * 365.25 + $diff->m * 30 + $diff->d + $diff->h/24 + $diff->i / 60; break; case "h": $total = ($diff->y * 365.25 + $diff->m * 30 + $diff->d) * 24 + $diff->h + $diff->i/60; break; case "i": $total = (($diff->y * 365.25 + $diff->m * 30 + $diff->d) * 24 + $diff->h) * 60 + $diff->i + $diff->s/60; break; case "s": $total = ((($diff->y * 365.25 + $diff->m * 30 + $diff->d) * 24 + $diff->h) * 60 + $diff->i)*60 + $diff->s; break; } if( $diff->invert) return -1 * $total; else return $total; } $begin = mktime(9, 15, 0, date("m") , date("d"), date("Y")); $end = mktime(14, 0, 0, date("m") , date("d"), date("Y")); echo "begin is $begin and end is $end<br>"; $begin_time = date("H:i:s", $begin); $end_time = date("H:i:s", $end); echo "begin_time is $begin_time and end_time is $end_time<br>"; $diff= date_diff(new DateTime($begin_time), new DateTime($end_time)); echo "diff is $diff";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vMusC
function name:  (null)
number of ops:  73
compiled vars:  !0 = $begin, !1 = $end, !2 = $begin_time, !3 = $end_time, !4 = $diff
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   35     0  E >   INIT_FCALL                                               'mktime'
          1        SEND_VAL                                                 9
          2        SEND_VAL                                                 15
          3        SEND_VAL                                                 0
          4        INIT_FCALL                                               'date'
          5        SEND_VAL                                                 'm'
          6        DO_ICALL                                         $5      
          7        SEND_VAR                                                 $5
          8        INIT_FCALL                                               'date'
          9        SEND_VAL                                                 'd'
         10        DO_ICALL                                         $6      
         11        SEND_VAR                                                 $6
         12        INIT_FCALL                                               'date'
         13        SEND_VAL                                                 'Y'
         14        DO_ICALL                                         $7      
         15        SEND_VAR                                                 $7
         16        DO_ICALL                                         $8      
         17        ASSIGN                                                   !0, $8
   36    18        INIT_FCALL                                               'mktime'
         19        SEND_VAL                                                 14
         20        SEND_VAL                                                 0
         21        SEND_VAL                                                 0
         22        INIT_FCALL                                               'date'
         23        SEND_VAL                                                 'm'
         24        DO_ICALL                                         $10     
         25        SEND_VAR                                                 $10
         26        INIT_FCALL                                               'date'
         27        SEND_VAL                                                 'd'
         28        DO_ICALL                                         $11     
         29        SEND_VAR                                                 $11
         30        INIT_FCALL                                               'date'
         31        SEND_VAL                                                 'Y'
         32        DO_ICALL                                         $12     
         33        SEND_VAR                                                 $12
         34        DO_ICALL                                         $13     
         35        ASSIGN                                                   !1, $13
   37    36        ROPE_INIT                                     5  ~16     'begin+is+'
         37        ROPE_ADD                                      1  ~16     ~16, !0
         38        ROPE_ADD                                      2  ~16     ~16, '+and+end+is+'
         39        ROPE_ADD                                      3  ~16     ~16, !1
         40        ROPE_END                                      4  ~15     ~16, '%3Cbr%3E'
         41        ECHO                                                     ~15
   38    42        INIT_FCALL                                               'date'
         43        SEND_VAL                                                 'H%3Ai%3As'
         44        SEND_VAR                                                 !0
         45        DO_ICALL                                         $19     
         46        ASSIGN                                                   !2, $19
   39    47        INIT_FCALL                                               'date'
         48        SEND_VAL                                                 'H%3Ai%3As'
         49        SEND_VAR                                                 !1
         50        DO_ICALL                                         $21     
         51        ASSIGN                                                   !3, $21
   40    52        ROPE_INIT                                     5  ~24     'begin_time+is+'
         53        ROPE_ADD                                      1  ~24     ~24, !2
         54        ROPE_ADD                                      2  ~24     ~24, '+and+end_time+is+'
         55        ROPE_ADD                                      3  ~24     ~24, !3
         56        ROPE_END                                      4  ~23     ~24, '%3Cbr%3E'
         57        ECHO                                                     ~23
   41    58        INIT_FCALL                                               'date_diff'
         59        NEW                                              $27     'DateTime'
         60        SEND_VAR_EX                                              !2
         61        DO_FCALL                                      0          
         62        SEND_VAR                                                 $27
         63        NEW                                              $29     'DateTime'
         64        SEND_VAR_EX                                              !3
         65        DO_FCALL                                      0          
         66        SEND_VAR                                                 $29
         67        DO_ICALL                                         $31     
         68        ASSIGN                                                   !4, $31
   42    69        NOP                                                      
         70        FAST_CONCAT                                      ~33     'diff+is+', !4
         71        ECHO                                                     ~33
         72      > RETURN                                                   1

Function s_datediff:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 10
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 16
Branch analysis from position: 12
8 jumps found. (Code = 188) Position 1 = 37, Position 2 = 46, Position 3 = 58, Position 4 = 73, Position 5 = 88, Position 6 = 106, Position 7 = 124, Position 8 = 24
Branch analysis from position: 37
1 jumps found. (Code = 42) Position 1 = 124
Branch analysis from position: 124
2 jumps found. (Code = 43) Position 1 = 126, Position 2 = 129
Branch analysis from position: 126
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 129
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 46
1 jumps found. (Code = 42) Position 1 = 124
Branch analysis from position: 124
Branch analysis from position: 58
1 jumps found. (Code = 42) Position 1 = 124
Branch analysis from position: 124
Branch analysis from position: 73
1 jumps found. (Code = 42) Position 1 = 124
Branch analysis from position: 124
Branch analysis from position: 88
1 jumps found. (Code = 42) Position 1 = 124
Branch analysis from position: 124
Branch analysis from position: 106
1 jumps found. (Code = 42) Position 1 = 124
Branch analysis from position: 124
Branch analysis from position: 124
Branch analysis from position: 24
2 jumps found. (Code = 44) Position 1 = 26, Position 2 = 37
Branch analysis from position: 26
2 jumps found. (Code = 44) Position 1 = 28, Position 2 = 46
Branch analysis from position: 28
2 jumps found. (Code = 44) Position 1 = 30, Position 2 = 58
Branch analysis from position: 30
2 jumps found. (Code = 44) Position 1 = 32, Position 2 = 73
Branch analysis from position: 32
2 jumps found. (Code = 44) Position 1 = 34, Position 2 = 88
Branch analysis from position: 34
2 jumps found. (Code = 44) Position 1 = 36, Position 2 = 106
Branch analysis from position: 36
1 jumps found. (Code = 42) Position 1 = 124
Branch analysis from position: 124
Branch analysis from position: 106
Branch analysis from position: 88
Branch analysis from position: 73
Branch analysis from position: 58
Branch analysis from position: 46
Branch analysis from position: 37
Branch analysis from position: 16
Branch analysis from position: 10
filename:       /in/vMusC
function name:  s_datediff
number of ops:  131
compiled vars:  !0 = $str_interval, !1 = $dt_menor, !2 = $dt_maior, !3 = $relative, !4 = $diff, !5 = $total
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
          3        RECV_INIT                                        !3      <false>
    5     4        TYPE_CHECK                                   64          !1
          5      > JMPZ                                                     ~6, ->10
          6    >   INIT_FCALL                                               'date_create'
          7        SEND_VAR                                                 !1
          8        DO_ICALL                                         $7      
          9        ASSIGN                                                   !1, $7
    6    10    >   TYPE_CHECK                                   64          !2
         11      > JMPZ                                                     ~9, ->16
         12    >   INIT_FCALL                                               'date_create'
         13        SEND_VAR                                                 !2
         14        DO_ICALL                                         $10     
         15        ASSIGN                                                   !2, $10
    8    16    >   INIT_FCALL                                               'date_diff'
         17        SEND_VAR                                                 !1
         18        SEND_VAR                                                 !2
         19        BOOL_NOT                                         ~12     !3
         20        SEND_VAL                                                 ~12
         21        DO_ICALL                                         $13     
         22        ASSIGN                                                   !4, $13
   10    23      > SWITCH_STRING                                            !0, [ 'y':->37, 'm':->46, 'd':->58, 'h':->73, 'i':->88, 's':->106, ], ->124
   11    24    >   IS_EQUAL                                                 !0, 'y'
         25      > JMPNZ                                                    ~15, ->37
   13    26    >   IS_EQUAL                                                 !0, 'm'
         27      > JMPNZ                                                    ~15, ->46
   16    28    >   IS_EQUAL                                                 !0, 'd'
         29      > JMPNZ                                                    ~15, ->58
   19    30    >   IS_EQUAL                                                 !0, 'h'
         31      > JMPNZ                                                    ~15, ->73
   22    32    >   IS_EQUAL                                                 !0, 'i'
         33      > JMPNZ                                                    ~15, ->88
   25    34    >   IS_EQUAL                                                 !0, 's'
         35      > JMPNZ                                                    ~15, ->106
         36    > > JMP                                                      ->124
   12    37    >   FETCH_OBJ_R                                      ~16     !4, 'y'
         38        FETCH_OBJ_R                                      ~17     !4, 'm'
         39        DIV                                              ~18     ~17, 12
         40        ADD                                              ~19     ~16, ~18
         41        FETCH_OBJ_R                                      ~20     !4, 'd'
         42        DIV                                              ~21     ~20, 365.25
         43        ADD                                              ~22     ~19, ~21
         44        ASSIGN                                                   !5, ~22
         45      > JMP                                                      ->124
   14    46    >   FETCH_OBJ_R                                      ~24     !4, 'y'
         47        MUL                                              ~25     ~24, 12
         48        FETCH_OBJ_R                                      ~26     !4, 'm'
         49        ADD                                              ~27     ~25, ~26
         50        FETCH_OBJ_R                                      ~28     !4, 'd'
         51        DIV                                              ~29     ~28, 30
         52        ADD                                              ~30     ~27, ~29
         53        FETCH_OBJ_R                                      ~31     !4, 'h'
         54        DIV                                              ~32     ~31, 24
         55        ADD                                              ~33     ~30, ~32
         56        ASSIGN                                                   !5, ~33
   15    57      > JMP                                                      ->124
   17    58    >   FETCH_OBJ_R                                      ~35     !4, 'y'
         59        MUL                                              ~36     ~35, 365.25
         60        FETCH_OBJ_R                                      ~37     !4, 'm'
         61        MUL                                              ~38     ~37, 30
         62        ADD                                              ~39     ~36, ~38
         63        FETCH_OBJ_R                                      ~40     !4, 'd'
         64        ADD                                              ~41     ~39, ~40
         65        FETCH_OBJ_R                                      ~42     !4, 'h'
         66        DIV                                              ~43     ~42, 24
         67        ADD                                              ~44     ~41, ~43
         68        FETCH_OBJ_R                                      ~45     !4, 'i'
         69        DIV                                              ~46     ~45, 60
         70        ADD                                              ~47     ~44, ~46
         71        ASSIGN                                                   !5, ~47
   18    72      > JMP                                                      ->124
   20    73    >   FETCH_OBJ_R                                      ~49     !4, 'y'
         74        MUL                                              ~50     ~49, 365.25
         75        FETCH_OBJ_R                                      ~51     !4, 'm'
         76        MUL                                              ~52     ~51, 30
         77        ADD                                              ~53     ~50, ~52
         78        FETCH_OBJ_R                                      ~54     !4, 'd'
         79        ADD                                              ~55     ~53, ~54
         80        MUL                                              ~56     ~55, 24
         81        FETCH_OBJ_R                                      ~57     !4, 'h'
         82        ADD                                              ~58     ~56, ~57
         83        FETCH_OBJ_R                                      ~59     !4, 'i'
         84        DIV                                              ~60     ~59, 60
         85        ADD                                              ~61     ~58, ~60
         86        ASSIGN                                                   !5, ~61
   21    87      > JMP                                                      ->124
   23    88    >   FETCH_OBJ_R                                      ~63     !4, 'y'
         89        MUL                                              ~64     ~63, 365.25
         90        FETCH_OBJ_R                                      ~65     !4, 'm'
         91        MUL                                              ~66     ~65, 30
         92        ADD                                              ~67     ~64, ~66
         93        FETCH_OBJ_R                                      ~68     !4, 'd'
         94        ADD                                              ~69     ~67, ~68
         95        MUL                                              ~70     ~69, 24
         96        FETCH_OBJ_R                                      ~71     !4, 'h'
         97        ADD                                              ~72     ~70, ~71
         98        MUL                                              ~73     ~72, 60
         99        FETCH_OBJ_R                                      ~74     !4, 'i'
        100        ADD                                              ~75     ~73, ~74
        101        FETCH_OBJ_R                                      ~76     !4, 's'
        102        DIV                                              ~77     ~76, 60
        103        ADD                                              ~78     ~75, ~77
        104        ASSIGN                                                   !5, ~78
   24   105      > JMP                                                      ->124
   26   106    >   FETCH_OBJ_R                                      ~80     !4, 'y'
        107        MUL                                              ~81     ~80, 365.25
        108        FETCH_OBJ_R                                      ~82     !4, 'm'
        109        MUL                                              ~83     ~82, 30
        110        ADD                                              ~84     ~81, ~83
        111        FETCH_OBJ_R                                      ~85     !4, 'd'
        112        ADD                                              ~86     ~84, ~85
        113        MUL                                              ~87     ~86, 24
        114        FETCH_OBJ_R                                      ~88     !4, 'h'
        115        ADD                                              ~89     ~87, ~88
        116        MUL                                              ~90     ~89, 60
        117        FETCH_OBJ_R                                      ~91     !4, 'i'
        118        ADD                                              ~92     ~90, ~91
        119        MUL                                              ~93     ~92, 60
        120        FETCH_OBJ_R                                      ~94     !4, 's'
        121        ADD                                              ~95     ~93, ~94
        122        ASSIGN                                                   !5, ~95
   27   123      > JMP                                                      ->124
   29   124    >   FETCH_OBJ_R                                      ~97     !4, 'invert'
        125      > JMPZ                                                     ~97, ->129
   30   126    >   MUL                                              ~98     !5, -1
        127      > RETURN                                                   ~98
        128*       JMP                                                      ->130
   31   129    > > RETURN                                                   !5
   32   130*     > RETURN                                                   null

End of function s_datediff

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148.03 ms | 1412 KiB | 21 Q