3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * @link https://stackoverflow.com/a/13129856/367456 */ $formats = array( 'today midnight', 'midnight', 'today', 'TODAY', 'MidNight', 'ToDaY', 'tomorrow', 'UTC today', 'today Z', 'today Europe/Berlin', 'Asia/Shanghai today', 'Asia/Shanghai', 'HKST today', ); /** * give each time (unix timestamp) its own color * * @param $time * @return string */ function time_color($time) { static $colors = array('black', 'copper', 'blue', 'lime', 'green', 'pink', 'red'); static $coloredTime = array(-1 => ' ?! '); if (!isset($coloredTime[$time])) { $coloredTime[$time] = array_pop($colors); } return $coloredTime[$time]; } $time = strtotime('UTC 2020-01-01 00:00:00'); $format1 = "(default time-zone is ..: %s)\n"; if (is_callable('date_default_timezone_get')) { printf($format1, date_default_timezone_get()); } else { printf($format1, '??? (unknown)'); } printf("UTC time is ............: [%-6s] %d (script-time, UTC 2020-01-01 00:00:00)\n", time_color($time), $time); foreach ($formats as $format) { $strToTime = strtotime($format, $time); printf("%'.-24s: [%-6s] %d\n", "$format ", time_color($strToTime), $strToTime); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 17
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
2 jumps found. (Code = 77) Position 1 = 30, Position 2 = 48
Branch analysis from position: 30
2 jumps found. (Code = 78) Position 1 = 31, Position 2 = 48
Branch analysis from position: 31
1 jumps found. (Code = 42) Position 1 = 30
Branch analysis from position: 30
Branch analysis from position: 48
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 48
Branch analysis from position: 17
2 jumps found. (Code = 77) Position 1 = 30, Position 2 = 48
Branch analysis from position: 30
Branch analysis from position: 48
filename:       /in/KWFJl
function name:  (null)
number of ops:  50
compiled vars:  !0 = $formats, !1 = $time, !2 = $format1, !3 = $format, !4 = $strToTime
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   ASSIGN                                                   !0, <array>
   37     1        INIT_FCALL                                               'strtotime'
          2        SEND_VAL                                                 'UTC+2020-01-01+00%3A00%3A00'
          3        DO_ICALL                                         $6      
          4        ASSIGN                                                   !1, $6
   39     5        ASSIGN                                                   !2, '%28default+time-zone+is+..%3A+%25s%29%0A'
   40     6        INIT_FCALL                                               'is_callable'
          7        SEND_VAL                                                 'date_default_timezone_get'
          8        DO_ICALL                                         $9      
          9      > JMPZ                                                     $9, ->17
   41    10    >   INIT_FCALL                                               'printf'
         11        SEND_VAR                                                 !2
         12        INIT_FCALL                                               'date_default_timezone_get'
         13        DO_ICALL                                         $10     
         14        SEND_VAR                                                 $10
         15        DO_ICALL                                                 
   40    16      > JMP                                                      ->21
   43    17    >   INIT_FCALL                                               'printf'
         18        SEND_VAR                                                 !2
         19        SEND_VAL                                                 '%3F%3F%3F+%28unknown%29'
         20        DO_ICALL                                                 
   46    21    >   INIT_FCALL                                               'printf'
         22        SEND_VAL                                                 'UTC+time+is+............%3A+%5B%25-6s%5D+%25d+%28script-time%2C+UTC+2020-01-01+00%3A00%3A00%29%0A'
         23        INIT_FCALL                                               'time_color'
         24        SEND_VAR                                                 !1
         25        DO_FCALL                                      0  $13     
         26        SEND_VAR                                                 $13
         27        SEND_VAR                                                 !1
         28        DO_ICALL                                                 
   48    29      > FE_RESET_R                                       $15     !0, ->48
         30    > > FE_FETCH_R                                               $15, !3, ->48
   49    31    >   INIT_FCALL                                               'strtotime'
         32        SEND_VAR                                                 !3
         33        SEND_VAR                                                 !1
         34        DO_ICALL                                         $16     
         35        ASSIGN                                                   !4, $16
   50    36        INIT_FCALL                                               'printf'
         37        SEND_VAL                                                 '%25%27.-24s%3A+%5B%25-6s%5D+%25d%0A'
         38        NOP                                                      
         39        FAST_CONCAT                                      ~18     !3, '+'
         40        SEND_VAL                                                 ~18
         41        INIT_FCALL                                               'time_color'
         42        SEND_VAR                                                 !4
         43        DO_FCALL                                      0  $19     
         44        SEND_VAR                                                 $19
         45        SEND_VAR                                                 !4
         46        DO_ICALL                                                 
   48    47      > JMP                                                      ->30
         48    >   FE_FREE                                                  $15
   51    49      > RETURN                                                   1

Function time_color:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 11
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
filename:       /in/KWFJl
function name:  time_color
number of ops:  14
compiled vars:  !0 = $time, !1 = $colors, !2 = $coloredTime
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   RECV                                             !0      
   29     1        BIND_STATIC                                              !1
   30     2        BIND_STATIC                                              !2
   31     3        ISSET_ISEMPTY_DIM_OBJ                         0  ~3      !2, !0
          4        BOOL_NOT                                         ~4      ~3
          5      > JMPZ                                                     ~4, ->11
   32     6    >   INIT_FCALL                                               'array_pop'
          7        SEND_REF                                                 !1
          8        DO_ICALL                                         $6      
          9        ASSIGN_DIM                                               !2, !0
         10        OP_DATA                                                  $6
   34    11    >   FETCH_DIM_R                                      ~7      !2, !0
         12      > RETURN                                                   ~7
   35    13*     > RETURN                                                   null

End of function time_color

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
170.46 ms | 1465 KiB | 20 Q