3v4l.org

run code in 300+ PHP versions simultaneously
<?php class WP_JSON_DateTime extends DateTime { /** * Workaround for DateTime::createFromFormat on PHP < 5.3 * Found on http://stackoverflow.com/a/17084893/717643 * * @param string $format The format that the passed in string should be in. * @param string $string String representing the time. * @param DateTimeZone $timezone A DateTimeZone object representing the desired time zone. * @return Datetime */ public static function createFromFormat($format, $time, $timezone = null) { if ( method_exists('DateTime', 'createFromFormat') ) { return parent::createFromFormat($format, $time, $timezone); } return new DateTime(date($format, strtotime($time)), $timezone); } } $timezone = new DateTimeZone('America/Mexico_City'); $date = WP_JSON_DateTime::createFromFormat('Y-m-d H:i:s', '2013-12-14 16:12:03', $timezone); echo $date->format('c'); echo '<br>'; echo $date->format('date_tz');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/WvbPE
function name:  (null)
number of ops:  20
compiled vars:  !0 = $timezone, !1 = $date
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   NEW                                              $2      'DateTimeZone'
          1        SEND_VAL_EX                                              'America%2FMexico_City'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $2
   24     4        INIT_STATIC_METHOD_CALL                                  'WP_JSON_DateTime', 'createFromFormat'
          5        SEND_VAL                                                 'Y-m-d+H%3Ai%3As'
          6        SEND_VAL                                                 '2013-12-14+16%3A12%3A03'
          7        SEND_VAR                                                 !0
          8        DO_FCALL                                      0  $5      
          9        ASSIGN                                                   !1, $5
   25    10        INIT_METHOD_CALL                                         !1, 'format'
         11        SEND_VAL_EX                                              'c'
         12        DO_FCALL                                      0  $7      
         13        ECHO                                                     $7
   26    14        ECHO                                                     '%3Cbr%3E'
   27    15        INIT_METHOD_CALL                                         !1, 'format'
         16        SEND_VAL_EX                                              'date_tz'
         17        DO_FCALL                                      0  $8      
         18        ECHO                                                     $8
         19      > RETURN                                                   1

Class WP_JSON_DateTime:
Function createfromformat:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 14
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/WvbPE
function name:  createFromFormat
number of ops:  27
compiled vars:  !0 = $format, !1 = $time, !2 = $timezone
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV_INIT                                        !2      null
   15     3        INIT_FCALL                                               'method_exists'
          4        SEND_VAL                                                 'DateTime'
          5        SEND_VAL                                                 'createFromFormat'
          6        DO_ICALL                                         $3      
          7      > JMPZ                                                     $3, ->14
   16     8    >   INIT_STATIC_METHOD_CALL                                  'createFromFormat'
          9        SEND_VAR_EX                                              !0
         10        SEND_VAR_EX                                              !1
         11        SEND_VAR_EX                                              !2
         12        DO_FCALL                                      0  $4      
         13      > RETURN                                                   $4
   19    14    >   NEW                                              $5      'DateTime'
         15        INIT_FCALL                                               'date'
         16        SEND_VAR                                                 !0
         17        INIT_FCALL                                               'strtotime'
         18        SEND_VAR                                                 !1
         19        DO_ICALL                                         $6      
         20        SEND_VAR                                                 $6
         21        DO_ICALL                                         $7      
         22        SEND_VAR_NO_REF_EX                                       $7
         23        SEND_VAR_EX                                              !2
         24        DO_FCALL                                      0          
         25      > RETURN                                                   $5
   20    26*     > RETURN                                                   null

End of function createfromformat

End of class WP_JSON_DateTime.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.57 ms | 1400 KiB | 19 Q