3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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) { }
based on N6GGa
Output for 7.2.0
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-11-07 03:27:21.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } object(DateTime)#2 (3) { ["date"]=> string(26) "2015-11-06 20:13:19.003935" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" }
Output for 7.1.10
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-11-07 03:27:21.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } object(DateTime)#2 (3) { ["date"]=> string(26) "2015-11-06 20:13:19.003338" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" }
Output for 7.1.7
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-11-07 03:27:21.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } object(DateTime)#2 (3) { ["date"]=> string(26) "2015-11-06 20:13:19.004074" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" }
Output for 7.1.6
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-11-07 03:27:21.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } object(DateTime)#2 (3) { ["date"]=> string(26) "2015-11-06 20:13:19.013168" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" }
Output for 7.1.5
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-11-07 03:27:21.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } object(DateTime)#2 (3) { ["date"]=> string(26) "2015-11-06 20:13:19.005356" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" }
Output for 7.1.0
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-11-07 03:27:21.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } object(DateTime)#2 (3) { ["date"]=> string(26) "2015-11-06 20:13:19.003942" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" }
Output for 5.6.28, 7.0.20
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-11-07 03:27:21.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } object(DateTime)#2 (3) { ["date"]=> string(26) "2015-11-06 20:13:19.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" }
Output for 7.0.6
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-11-07 03:27:21.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } object(DateTime)#2 (3) { ["date"]=> string(26) "2016-05-03 16:27:45.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" }
Output for 7.0.5
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-11-07 03:27:21.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } object(DateTime)#2 (3) { ["date"]=> string(26) "2016-04-03 04:53:03.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" }
Output for 7.0.4
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-11-07 03:27:21.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } object(DateTime)#2 (3) { ["date"]=> string(26) "2016-03-10 17:39:41.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" }
Output for 7.0.3
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-11-07 03:27:21.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } object(DateTime)#2 (3) { ["date"]=> string(26) "2016-03-18 18:48:04.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" }
Output for 7.0.2
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-11-07 03:27:21.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } object(DateTime)#2 (3) { ["date"]=> string(26) "2016-03-23 00:55:31.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" }
Output for 7.0.1
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-11-07 03:27:21.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } object(DateTime)#2 (3) { ["date"]=> string(26) "2016-03-24 04:35:12.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" }
Output for 7.0.0
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-11-07 03:27:21.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } object(DateTime)#2 (3) { ["date"]=> string(26) "2016-03-27 05:31:27.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" }
Output for 5.6.21
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-11-07 03:27:21.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } object(DateTime)#2 (3) { ["date"]=> string(26) "2016-05-02 11:36:57.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" }
Output for 5.6.20
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-11-07 03:27:21.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } object(DateTime)#2 (3) { ["date"]=> string(26) "2016-04-10 03:52:21.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" }
Output for 5.6.19
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-11-07 03:27:21.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } object(DateTime)#2 (3) { ["date"]=> string(26) "2016-03-08 01:51:02.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" }
Output for 5.6.18
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-11-07 03:27:21.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } object(DateTime)#2 (3) { ["date"]=> string(26) "2016-03-15 10:34:21.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" }
Output for 5.6.17
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-11-07 03:27:21.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } object(DateTime)#2 (3) { ["date"]=> string(26) "2016-03-19 22:13:59.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" }
Output for 5.6.16
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-11-07 03:27:21.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } object(DateTime)#2 (3) { ["date"]=> string(26) "2016-03-28 06:18:46.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" }
Output for 5.6.15
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-11-07 03:27:21.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } object(DateTime)#2 (3) { ["date"]=> string(26) "2016-03-29 07:09:25.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" }
Output for 5.6.14
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-11-07 03:27:21.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } object(DateTime)#2 (3) { ["date"]=> string(26) "2016-04-02 09:00:33.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" }
Output for 5.6.13
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-11-07 03:27:21.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } object(DateTime)#2 (3) { ["date"]=> string(26) "2016-04-15 13:24:48.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" }
Output for 5.6.12
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-11-07 03:27:21.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } object(DateTime)#2 (3) { ["date"]=> string(26) "2016-04-20 03:53:46.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" }
Output for 5.6.11
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-11-07 03:27:21.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } object(DateTime)#2 (3) { ["date"]=> string(26) "2016-04-24 10:16:07.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" }
Output for 5.6.10
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-11-07 03:27:21.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } object(DateTime)#2 (3) { ["date"]=> string(26) "2016-04-25 12:19:12.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" }
Output for 5.6.9
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-11-07 03:27:21.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } object(DateTime)#2 (3) { ["date"]=> string(26) "2016-04-27 17:29:21.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" }
Output for 5.6.8
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-11-07 03:27:21.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } object(DateTime)#2 (3) { ["date"]=> string(26) "2016-04-30 02:21:33.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" }
Output for 5.5.35
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-11-07 03:27:21.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } object(DateTime)#2 (3) { ["date"]=> string(26) "2016-05-22 18:45:21.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" }
Output for 5.5.34
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-11-07 03:27:21.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } object(DateTime)#2 (3) { ["date"]=> string(26) "2016-04-11 06:04:12.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" }
Output for 5.5.33
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-11-07 03:27:21.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } object(DateTime)#2 (3) { ["date"]=> string(26) "2016-03-09 04:34:04.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" }
Output for 5.5.32
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-11-07 03:27:21.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } object(DateTime)#2 (3) { ["date"]=> string(26) "2016-03-17 14:29:35.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" }
Output for 5.5.31
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-11-07 03:27:21.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } object(DateTime)#2 (3) { ["date"]=> string(26) "2016-03-21 01:15:46.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" }
Output for 5.5.30
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-11-07 03:27:21.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } object(DateTime)#2 (3) { ["date"]=> string(26) "2016-04-01 09:03:08.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" }
Output for 5.5.29
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-11-07 03:27:21.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } object(DateTime)#2 (3) { ["date"]=> string(26) "2016-04-17 03:48:05.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" }
Output for 5.5.28
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-11-07 03:27:21.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } object(DateTime)#2 (3) { ["date"]=> string(26) "2016-04-21 07:07:37.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" }
Output for 5.5.27
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-11-07 03:27:21.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } object(DateTime)#2 (3) { ["date"]=> string(26) "2016-04-22 08:54:12.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" }
Output for 5.5.26
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-11-07 03:27:21.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } object(DateTime)#2 (3) { ["date"]=> string(26) "2016-04-26 15:01:52.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" }
Output for 5.5.25
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-11-07 03:27:21.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } object(DateTime)#2 (3) { ["date"]=> string(26) "2016-04-28 21:54:22.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" }
Output for 5.5.24
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-11-07 03:27:21.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } object(DateTime)#2 (3) { ["date"]=> string(26) "2016-05-24 04:27:21.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" }
Output for 5.4.44 - 5.4.45
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-11-07 03:27:21.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } object(DateTime)#2 (3) { ["date"]=> string(26) "2015-11-06 20:13:32.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" }
Output for 5.4.36 - 5.4.43
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-11-07 03:27:21.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } object(DateTime)#2 (3) { ["date"]=> string(26) "2015-11-06 20:13:33.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" }
Output for 5.4.30 - 5.4.35
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-11-07 03:27:21.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } object(DateTime)#2 (3) { ["date"]=> string(26) "2015-11-06 20:13:34.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" }
Output for 5.4.28 - 5.4.29
object(DateTime)#1 (3) { ["date"]=> string(19) "2015-11-07 03:27:21" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } object(DateTime)#2 (3) { ["date"]=> string(19) "2015-11-06 20:13:34" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" }
Output for 5.4.21 - 5.4.27
object(DateTime)#1 (3) { ["date"]=> string(19) "2015-11-07 03:27:21" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } object(DateTime)#2 (3) { ["date"]=> string(19) "2015-11-06 20:13:35" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" }
Output for 5.4.14 - 5.4.20
object(DateTime)#1 (3) { ["date"]=> string(19) "2015-11-07 03:27:21" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } object(DateTime)#2 (3) { ["date"]=> string(19) "2015-11-06 20:13:36" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" }
Output for 5.4.6 - 5.4.13
object(DateTime)#1 (3) { ["date"]=> string(19) "2015-11-07 03:27:21" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } object(DateTime)#2 (3) { ["date"]=> string(19) "2015-11-06 20:13:37" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" }
Output for 5.3.28 - 5.4.5
object(DateTime)#1 (3) { ["date"]=> string(19) "2015-11-07 03:27:21" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } object(DateTime)#2 (3) { ["date"]=> string(19) "2015-11-06 20:13:38" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" }
Output for 5.3.20 - 5.3.27
object(DateTime)#1 (3) { ["date"]=> string(19) "2015-11-07 03:27:21" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } object(DateTime)#2 (3) { ["date"]=> string(19) "2015-11-06 20:13:39" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" }
Output for 5.3.19
object(DateTime)#1 (3) { ["date"]=> string(19) "2015-11-07 03:27:21" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } object(DateTime)#2 (3) { ["date"]=> string(19) "2015-11-06 20:13:40" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" }