3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MyDateTime { public static function createFromFormat($dformat, $dvalue) { $schedule = $dvalue; $schedule_format = str_replace(array('Y','m','d', 'H', 'i','a'),array('%Y','%m','%d', '%I', '%M', '%p' ) ,$dformat); // %Y, %m and %d correspond to date()'s Y m and d. // %I corresponds to H, %M to i and %p to a $ugly = strptime($schedule, $schedule_format); $ymd = sprintf( // This is a format string that takes six total decimal // arguments, then left-pads them with zeros to either // 4 or 2 characters, as needed '%04d-%02d-%02d %02d:%02d:%02d', $ugly['tm_year'] + 1900, // This will be "111", so we need to add 1900. $ugly['tm_mon'] + 1, // This will be the month minus one, so we add one. $ugly['tm_mday'], $ugly['tm_hour'], $ugly['tm_min'], $ugly['tm_sec'] ); $new_schedule = new DateTime($ymd); return $new_schedule; } public static function getTimestamp($dateTime) { return $dateTime->format('U'); }} $dateTime = MyDateTime::createFromFormat('d/m/Y', '13/06/2013'); var_dump($dateTime); var_dump($dateTime->format('Y-m-d')); var_dump(MyDateTime::getTimeStamp($dateTime));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/mXtBo
function name:  (null)
number of ops:  21
compiled vars:  !0 = $dateTime
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   INIT_STATIC_METHOD_CALL                                  'MyDateTime', 'createFromFormat'
          1        SEND_VAL                                                 'd%2Fm%2FY'
          2        SEND_VAL                                                 '13%2F06%2F2013'
          3        DO_FCALL                                      0  $1      
          4        ASSIGN                                                   !0, $1
   30     5        INIT_FCALL                                               'var_dump'
          6        SEND_VAR                                                 !0
          7        DO_ICALL                                                 
   31     8        INIT_FCALL                                               'var_dump'
          9        INIT_METHOD_CALL                                         !0, 'format'
         10        SEND_VAL_EX                                              'Y-m-d'
         11        DO_FCALL                                      0  $4      
         12        SEND_VAR                                                 $4
         13        DO_ICALL                                                 
   32    14        INIT_FCALL                                               'var_dump'
         15        INIT_STATIC_METHOD_CALL                                  'MyDateTime', 'getTimeStamp'
         16        SEND_VAR                                                 !0
         17        DO_FCALL                                      0  $6      
         18        SEND_VAR                                                 $6
         19        DO_ICALL                                                 
         20      > RETURN                                                   1

Class MyDateTime:
Function createfromformat:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/mXtBo
function name:  createFromFormat
number of ops:  38
compiled vars:  !0 = $dformat, !1 = $dvalue, !2 = $schedule, !3 = $schedule_format, !4 = $ugly, !5 = $ymd, !6 = $new_schedule
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    4     2        ASSIGN                                                   !2, !1
    5     3        INIT_FCALL                                               'str_replace'
          4        SEND_VAL                                                 <array>
          5        SEND_VAL                                                 <array>
          6        SEND_VAR                                                 !0
          7        DO_ICALL                                         $8      
          8        ASSIGN                                                   !3, $8
    8     9        INIT_FCALL                                               'strptime'
         10        SEND_VAR                                                 !2
         11        SEND_VAR                                                 !3
         12        DO_ICALL                                         $10     
         13        ASSIGN                                                   !4, $10
    9    14        INIT_FCALL                                               'sprintf'
   13    15        SEND_VAL                                                 '%2504d-%2502d-%2502d+%2502d%3A%2502d%3A%2502d'
   14    16        FETCH_DIM_R                                      ~12     !4, 'tm_year'
         17        ADD                                              ~13     ~12, 1900
         18        SEND_VAL                                                 ~13
   15    19        FETCH_DIM_R                                      ~14     !4, 'tm_mon'
         20        ADD                                              ~15     ~14, 1
         21        SEND_VAL                                                 ~15
   16    22        FETCH_DIM_R                                      ~16     !4, 'tm_mday'
         23        SEND_VAL                                                 ~16
   17    24        FETCH_DIM_R                                      ~17     !4, 'tm_hour'
         25        SEND_VAL                                                 ~17
   18    26        FETCH_DIM_R                                      ~18     !4, 'tm_min'
         27        SEND_VAL                                                 ~18
   19    28        FETCH_DIM_R                                      ~19     !4, 'tm_sec'
         29        SEND_VAL                                                 ~19
         30        DO_ICALL                                         $20     
    9    31        ASSIGN                                                   !5, $20
   21    32        NEW                                              $22     'DateTime'
         33        SEND_VAR_EX                                              !5
         34        DO_FCALL                                      0          
         35        ASSIGN                                                   !6, $22
   23    36      > RETURN                                                   !6
   24    37*     > RETURN                                                   null

End of function createfromformat

Function gettimestamp:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/mXtBo
function name:  getTimestamp
number of ops:  6
compiled vars:  !0 = $dateTime
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   RECV                                             !0      
   27     1        INIT_METHOD_CALL                                         !0, 'format'
          2        SEND_VAL_EX                                              'U'
          3        DO_FCALL                                      0  $1      
          4      > RETURN                                                   $1
          5*     > RETURN                                                   null

End of function gettimestamp

End of class MyDateTime.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.75 ms | 1400 KiB | 21 Q