3v4l.org

run code in 300+ PHP versions simultaneously
<?php function get_timezone_offset($remote_tz, $origin_tz = null) { if($origin_tz === null) { if(!is_string($origin_tz = date_default_timezone_get())) { return false; // A UTC timestamp was returned -- bail out! } } $origin_dtz = new DateTimeZone($origin_tz); $remote_dtz = new DateTimeZone($remote_tz); $origin_dt = new DateTime("now", $origin_dtz); $remote_dt = new DateTime("now", $remote_dtz); $offset = $origin_dtz->getOffset($origin_dt) - $remote_dtz->getOffset($remote_dt); return $offset; } $offset = get_timezone_offset('America/Los_Angeles'); $offset_time = time() + $offset; echo $offset_time;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/AoKKT
function name:  (null)
number of ops:  10
compiled vars:  !0 = $offset, !1 = $offset_time
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   INIT_FCALL                                               'get_timezone_offset'
          1        SEND_VAL                                                 'America%2FLos_Angeles'
          2        DO_FCALL                                      0  $2      
          3        ASSIGN                                                   !0, $2
   18     4        INIT_FCALL                                               'time'
          5        DO_ICALL                                         $4      
          6        ADD                                              ~5      $4, !0
          7        ASSIGN                                                   !1, ~5
   20     8        ECHO                                                     !1
          9      > RETURN                                                   1

Function get_timezone_offset:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 11
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 11
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
filename:       /in/AoKKT
function name:  get_timezone_offset
number of ops:  39
compiled vars:  !0 = $remote_tz, !1 = $origin_tz, !2 = $origin_dtz, !3 = $remote_dtz, !4 = $origin_dt, !5 = $remote_dt, !6 = $offset
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      null
    4     2        TYPE_CHECK                                    2          !1
          3      > JMPZ                                                     ~7, ->11
    5     4    >   INIT_FCALL                                               'date_default_timezone_get'
          5        DO_ICALL                                         $8      
          6        ASSIGN                                           ~9      !1, $8
          7        TYPE_CHECK                                   64  ~10     ~9
          8        BOOL_NOT                                         ~11     ~10
          9      > JMPZ                                                     ~11, ->11
    6    10    > > RETURN                                                   <false>
    9    11    >   NEW                                              $12     'DateTimeZone'
         12        SEND_VAR_EX                                              !1
         13        DO_FCALL                                      0          
         14        ASSIGN                                                   !2, $12
   10    15        NEW                                              $15     'DateTimeZone'
         16        SEND_VAR_EX                                              !0
         17        DO_FCALL                                      0          
         18        ASSIGN                                                   !3, $15
   11    19        NEW                                              $18     'DateTime'
         20        SEND_VAL_EX                                              'now'
         21        SEND_VAR_EX                                              !2
         22        DO_FCALL                                      0          
         23        ASSIGN                                                   !4, $18
   12    24        NEW                                              $21     'DateTime'
         25        SEND_VAL_EX                                              'now'
         26        SEND_VAR_EX                                              !3
         27        DO_FCALL                                      0          
         28        ASSIGN                                                   !5, $21
   13    29        INIT_METHOD_CALL                                         !2, 'getOffset'
         30        SEND_VAR_EX                                              !4
         31        DO_FCALL                                      0  $24     
         32        INIT_METHOD_CALL                                         !3, 'getOffset'
         33        SEND_VAR_EX                                              !5
         34        DO_FCALL                                      0  $25     
         35        SUB                                              ~26     $24, $25
         36        ASSIGN                                                   !6, ~26
   14    37      > RETURN                                                   !6
   15    38*     > RETURN                                                   null

End of function get_timezone_offset

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.7 ms | 1403 KiB | 18 Q