3v4l.org

run code in 300+ PHP versions simultaneously
<?php $user_date_str = '2015/11/06 19:27:21'; $user_tz = 'America/Los_Angeles'; $server_tz = 'UTC'; // Get a DateTime object for the user entered time $user_datetime = new DateTime($user_date_str, new DateTimeZone($user_tz) ); // Change time zone to the same as the server $user_datetime->setTimeZone(new DateTimeZone($server_tz)); // Get a DateTime object for the current server time $server_datetime = new DateTime(); // If the PHP timezone isn't set correctly, you can also do: //$server_datetime = new DateTime(null, new DateTimeZone($server_tz) ); var_dump($user_datetime, $server_datetime); // Now compare if ($user_datetime < $server_datetime) { }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 26, Position 2 = 26
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
filename:       /in/N6GGa
function name:  (null)
number of ops:  27
compiled vars:  !0 = $user_date_str, !1 = $user_tz, !2 = $server_tz, !3 = $user_datetime, !4 = $server_datetime
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '2015%2F11%2F06+19%3A27%3A21'
    4     1        ASSIGN                                                   !1, 'America%2FLos_Angeles'
    5     2        ASSIGN                                                   !2, 'UTC'
    8     3        NEW                                              $8      'DateTime'
          4        SEND_VAR_EX                                              !0
          5        NEW                                              $9      'DateTimeZone'
          6        SEND_VAR_EX                                              !1
          7        DO_FCALL                                      0          
          8        SEND_VAR_NO_REF_EX                                       $9
          9        DO_FCALL                                      0          
         10        ASSIGN                                                   !3, $8
   10    11        INIT_METHOD_CALL                                         !3, 'setTimeZone'
         12        NEW                                              $13     'DateTimeZone'
         13        SEND_VAR_EX                                              !2
         14        DO_FCALL                                      0          
         15        SEND_VAR_NO_REF_EX                                       $13
         16        DO_FCALL                                      0          
   13    17        NEW                                              $16     'DateTime'
         18        DO_FCALL                                      0          
         19        ASSIGN                                                   !4, $16
   17    20        INIT_FCALL                                               'var_dump'
         21        SEND_VAR                                                 !3
         22        SEND_VAR                                                 !4
         23        DO_ICALL                                                 
   19    24        IS_SMALLER                                               !3, !4
         25      > JMPZ                                                     ~20, ->26
   21    26    > > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
173.06 ms | 1395 KiB | 15 Q