3v4l.org

run code in 300+ PHP versions simultaneously
<?php function converteData($format, $to_format, $date, $timezone = null) { if (!$timezone) { $timezone = new DateTimeZone(date_default_timezone_get()); } $d = date_create_from_format($format, $date, $timezone); return date_format($d, $to_format); } /* * Exemplos */ var_dump(converteData('d m Y', 'Y-m-d', '06 02 2025')); //2025-02-06 var_dump(converteData('d-m-Y', 'm/d/Y H:i', '06-02-2025')); //2025-02-06 var_dump(converteData('Y-m-d', 'D l F Y', '2025-02-06')); //2025-02-06
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/RHX2Q
function name:  (null)
number of ops:  25
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   INIT_FCALL                                               'var_dump'
          1        INIT_FCALL                                               'convertedata'
          2        SEND_VAL                                                 'd+m+Y'
          3        SEND_VAL                                                 'Y-m-d'
          4        SEND_VAL                                                 '06+02+2025'
          5        DO_FCALL                                      0  $0      
          6        SEND_VAR                                                 $0
          7        DO_ICALL                                                 
   17     8        INIT_FCALL                                               'var_dump'
          9        INIT_FCALL                                               'convertedata'
         10        SEND_VAL                                                 'd-m-Y'
         11        SEND_VAL                                                 'm%2Fd%2FY+H%3Ai'
         12        SEND_VAL                                                 '06-02-2025'
         13        DO_FCALL                                      0  $2      
         14        SEND_VAR                                                 $2
         15        DO_ICALL                                                 
   18    16        INIT_FCALL                                               'var_dump'
         17        INIT_FCALL                                               'convertedata'
         18        SEND_VAL                                                 'Y-m-d'
         19        SEND_VAL                                                 'D+l+F+Y'
         20        SEND_VAL                                                 '2025-02-06'
         21        DO_FCALL                                      0  $4      
         22        SEND_VAR                                                 $4
         23        DO_ICALL                                                 
         24      > RETURN                                                   1

Function convertedata:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 12
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
filename:       /in/RHX2Q
function name:  converteData
number of ops:  24
compiled vars:  !0 = $format, !1 = $to_format, !2 = $date, !3 = $timezone, !4 = $d
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
          3        RECV_INIT                                        !3      null
    4     4        BOOL_NOT                                         ~5      !3
          5      > JMPZ                                                     ~5, ->12
    5     6    >   NEW                                              $6      'DateTimeZone'
          7        INIT_FCALL                                               'date_default_timezone_get'
          8        DO_ICALL                                         $7      
          9        SEND_VAR_NO_REF_EX                                       $7
         10        DO_FCALL                                      0          
         11        ASSIGN                                                   !3, $6
    8    12    >   INIT_FCALL                                               'date_create_from_format'
         13        SEND_VAR                                                 !0
         14        SEND_VAR                                                 !2
         15        SEND_VAR                                                 !3
         16        DO_ICALL                                         $10     
         17        ASSIGN                                                   !4, $10
    9    18        INIT_FCALL                                               'date_format'
         19        SEND_VAR                                                 !4
         20        SEND_VAR                                                 !1
         21        DO_ICALL                                         $12     
         22      > RETURN                                                   $12
   10    23*     > RETURN                                                   null

End of function convertedata

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.55 ms | 1394 KiB | 24 Q