3v4l.org

run code in 300+ PHP versions simultaneously
<?php $schedule = '31/03/2011 01:22 pm'; // %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, '%d/%m/%Y %I:%M %p'); $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'] ); echo $ymd; $new_schedule = new DateTime($ymd); echo $new_schedule->format('Y-m-d H:i:s'); ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/GOIBK
function name:  (null)
number of ops:  34
compiled vars:  !0 = $schedule, !1 = $ugly, !2 = $ymd, !3 = $new_schedule
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, '31%2F03%2F2011+01%3A22+pm'
    5     1        INIT_FCALL                                               'strptime'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 '%25d%2F%25m%2F%25Y+%25I%3A%25M+%25p'
          4        DO_ICALL                                         $5      
          5        ASSIGN                                                   !1, $5
    6     6        INIT_FCALL                                               'sprintf'
   10     7        SEND_VAL                                                 '%2504d-%2502d-%2502d+%2502d%3A%2502d%3A%2502d'
   11     8        FETCH_DIM_R                                      ~7      !1, 'tm_year'
          9        ADD                                              ~8      ~7, 1900
         10        SEND_VAL                                                 ~8
   12    11        FETCH_DIM_R                                      ~9      !1, 'tm_mon'
         12        ADD                                              ~10     ~9, 1
         13        SEND_VAL                                                 ~10
   13    14        FETCH_DIM_R                                      ~11     !1, 'tm_mday'
         15        SEND_VAL                                                 ~11
   14    16        FETCH_DIM_R                                      ~12     !1, 'tm_hour'
         17        SEND_VAL                                                 ~12
   15    18        FETCH_DIM_R                                      ~13     !1, 'tm_min'
         19        SEND_VAL                                                 ~13
   16    20        FETCH_DIM_R                                      ~14     !1, 'tm_sec'
         21        SEND_VAL                                                 ~14
         22        DO_ICALL                                         $15     
    6    23        ASSIGN                                                   !2, $15
   18    24        ECHO                                                     !2
   19    25        NEW                                              $17     'DateTime'
         26        SEND_VAR_EX                                              !2
         27        DO_FCALL                                      0          
         28        ASSIGN                                                   !3, $17
   20    29        INIT_METHOD_CALL                                         !3, 'format'
         30        SEND_VAL_EX                                              'Y-m-d+H%3Ai%3As'
         31        DO_FCALL                                      0  $20     
         32        ECHO                                                     $20
   21    33      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
175 ms | 1396 KiB | 17 Q