3v4l.org

run code in 300+ PHP versions simultaneously
<?php date_default_timezone_set('Europe/Budapest'); function DateToDate($datestring,$timezone2='UTC') { //convert date to other zone: DateToDate(thisDate,inThisZone); //DateToDate("YYYY-MM-DD HH:MM:SSphpTimezoneName",phpTimezoneName ); //return a string: YYYY-MM-DD HH:MM:SS TimeZoneCode $date= substr($datestring, 0, 19); if (strlen($datestring) > 19) { $timezone=substr($datestring, 19); $date1 = new DateTime($date, new DateTimeZone($timezone) ); } else { $date1 = new DateTime($date); } //echo $datetime->format('Y-m-d H:i:s') . "\n"; $date2 = new DateTimeZone($timezone2); $date1->setTimezone($date2); $output=$date1->format('Y-m-d H:i:s T'); unset($date1); unset($date2); return $output; } echo DateToDate("2014-10-21 11:11:11Europe/Budapest","America/Los_Angeles"); echo '<br><br>'; //echo GetTimeInterval("2014-10-21 11:11:11Europe/Budapest","2014-10-21 11:11:11America/Los_Angeles",3); ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/RKv3K
function name:  (null)
number of ops:  10
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   INIT_FCALL                                               'date_default_timezone_set'
          1        SEND_VAL                                                 'Europe%2FBudapest'
          2        DO_ICALL                                                 
   34     3        INIT_FCALL                                               'datetodate'
          4        SEND_VAL                                                 '2014-10-21+11%3A11%3A11Europe%2FBudapest'
          5        SEND_VAL                                                 'America%2FLos_Angeles'
          6        DO_FCALL                                      0  $1      
          7        ECHO                                                     $1
   36     8        ECHO                                                     '%3Cbr%3E%3Cbr%3E'
   40     9      > RETURN                                                   1

Function datetodate:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 25
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 25
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/RKv3K
function name:  DateToDate
number of ops:  44
compiled vars:  !0 = $datestring, !1 = $timezone2, !2 = $date, !3 = $timezone, !4 = $date1, !5 = $date2, !6 = $output
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      'UTC'
   10     2        INIT_FCALL                                               'substr'
          3        SEND_VAR                                                 !0
          4        SEND_VAL                                                 0
          5        SEND_VAL                                                 19
          6        DO_ICALL                                         $7      
          7        ASSIGN                                                   !2, $7
   12     8        STRLEN                                           ~9      !0
          9        IS_SMALLER                                               19, ~9
         10      > JMPZ                                                     ~10, ->25
   14    11    >   INIT_FCALL                                               'substr'
         12        SEND_VAR                                                 !0
         13        SEND_VAL                                                 19
         14        DO_ICALL                                         $11     
         15        ASSIGN                                                   !3, $11
   15    16        NEW                                              $13     'DateTime'
         17        SEND_VAR_EX                                              !2
         18        NEW                                              $14     'DateTimeZone'
         19        SEND_VAR_EX                                              !3
         20        DO_FCALL                                      0          
         21        SEND_VAR_NO_REF_EX                                       $14
         22        DO_FCALL                                      0          
         23        ASSIGN                                                   !4, $13
         24      > JMP                                                      ->29
   20    25    >   NEW                                              $18     'DateTime'
         26        SEND_VAR_EX                                              !2
         27        DO_FCALL                                      0          
         28        ASSIGN                                                   !4, $18
   24    29    >   NEW                                              $21     'DateTimeZone'
         30        SEND_VAR_EX                                              !1
         31        DO_FCALL                                      0          
         32        ASSIGN                                                   !5, $21
   25    33        INIT_METHOD_CALL                                         !4, 'setTimezone'
         34        SEND_VAR_EX                                              !5
         35        DO_FCALL                                      0          
   27    36        INIT_METHOD_CALL                                         !4, 'format'
         37        SEND_VAL_EX                                              'Y-m-d+H%3Ai%3As+T'
         38        DO_FCALL                                      0  $25     
         39        ASSIGN                                                   !6, $25
   28    40        UNSET_CV                                                 !4
   29    41        UNSET_CV                                                 !5
   30    42      > RETURN                                                   !6
   31    43*     > RETURN                                                   null

End of function datetodate

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
140.69 ms | 1403 KiB | 18 Q