3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php //$connection = mysql_connect('localhost', 'root','abcABC123'); //mysql_select_db('pearson', $connection); //ini_set('date.timezone', 'US/Eastern'); //date_default_timezone_set('Europe/London'); echo "PHP INI SETTING : " . ini_get('date.timezone') . "</br>"; echo "Current timezone: " . date_default_timezone_get() . "</br>"; $date = new DateTime(); var_dump(new DateTime()); echo "</br>------------------------------------ DateTime Constants -------------------------------------------------</br>"; echo "DATE_ATOM - " . $date->format(DATE_ATOM) . "</br>" ; echo "DATE_ISO8601 - " . $date->format(DATE_ISO8601) . "</br>" ; echo "DATE_RFC822 - " . $date->format(DATE_RFC822) . "</br>" ; echo "DATE_RSS - " . $date->format(DATE_RSS) . "</br>" ; echo "</br>-------------------------------------- Operation with Date -----------------------------------------------</br>"; echo "Offset to GMT - " . $date->getOffset() . "</br>" ; echo "Date modify - " . $date->modify('+2 week')->format(DATE_RSS) . "</br>" ; echo "</br>-------------------------------------- Operation with Timezone -----------------------------------------------</br>"; echo "http://www.php.net/manual/en/datetime.configuration.php#ini.date.timezone </br>" ; echo "Timestamp - " . $date->getTimestamp(). "</br>" ; $timeZone = new DateTimeZone("Europe/Moscow"); $date->setTimezone($timeZone); //var_dump($timeZone->getTransitions()); //var_dump(timezone_identifiers_list()); var_dump($date); echo "Timezone offset to GMT - " . $timeZone->getOffset(new DateTime()) . "</br>" ; echo "</br>-------------------------------------- MYSQL -----------------------------------------------</br>" ; $sql = "INSERT INTO date_date(my_timestamp, datetime) VALUES(\"". CURRENT_TIMESTAMP . "\",\"" . $date->format("d-m-y H:i:s") . "\")"; echo $sql . "</br>"; mysql_query($sql); $result = mysql_query('SELECT datetime FROM date_date'); while ($row = mysql_fetch_assoc($result)) { $userTimeZone = new DateTimeZone('Europe/Oslo'); if (!empty($row["datetime"])) { $dt = new DateTime($row["datetime"]); $dt->setTimezone($userTimeZone); echo "</br>" . $dt->format("r") . "</br>"; } } echo "</br>-------------------------------------- Prooof links-----------------------------------------------</br>" ; echo "http://www.worldtimezone.com/index24.php </br>" ; echo "http://www.sitepoint.com/forums/showthread.php?450107-Difference-between-GMT-and-PST#post3243632</br>" ;
Output for 7.1.0
PHP INI SETTING : Europe/Amsterdam</br>Current timezone: Europe/Amsterdam</br>object(DateTime)#2 (3) { ["date"]=> string(26) "2014-12-17 10:53:48.006567" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } </br>------------------------------------ DateTime Constants -------------------------------------------------</br>DATE_ATOM - 2014-12-17T10:53:48+01:00</br>DATE_ISO8601 - 2014-12-17T10:53:48+0100</br>DATE_RFC822 - Wed, 17 Dec 14 10:53:48 +0100</br>DATE_RSS - Wed, 17 Dec 2014 10:53:48 +0100</br></br>-------------------------------------- Operation with Date -----------------------------------------------</br>Offset to GMT - 3600</br>Date modify - Wed, 31 Dec 2014 10:53:48 +0100</br></br>-------------------------------------- Operation with Timezone -----------------------------------------------</br>http://www.php.net/manual/en/datetime.configuration.php#ini.date.timezone </br>Timestamp - 1420019628</br>object(DateTime)#1 (3) { ["date"]=> string(26) "2014-12-31 12:53:48.006561" ["timezone_type"]=> int(3) ["timezone"]=> string(13) "Europe/Moscow" } Timezone offset to GMT - 10800</br></br>-------------------------------------- MYSQL -----------------------------------------------</br> Notice: Use of undefined constant CURRENT_TIMESTAMP - assumed 'CURRENT_TIMESTAMP' in /in/RGLEh on line 40 INSERT INTO date_date(my_timestamp, datetime) VALUES("CURRENT_TIMESTAMP","31-12-14 12:53:48")</br> Fatal error: Uncaught Error: Call to undefined function mysql_query() in /in/RGLEh:42 Stack trace: #0 {main} thrown in /in/RGLEh on line 42
Process exited with code 255.
Output for 7.0.14
PHP INI SETTING : Europe/Amsterdam</br>Current timezone: Europe/Amsterdam</br>object(DateTime)#2 (3) { ["date"]=> string(26) "2014-12-17 10:53:48.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } </br>------------------------------------ DateTime Constants -------------------------------------------------</br>DATE_ATOM - 2014-12-17T10:53:48+01:00</br>DATE_ISO8601 - 2014-12-17T10:53:48+0100</br>DATE_RFC822 - Wed, 17 Dec 14 10:53:48 +0100</br>DATE_RSS - Wed, 17 Dec 2014 10:53:48 +0100</br></br>-------------------------------------- Operation with Date -----------------------------------------------</br>Offset to GMT - 3600</br>Date modify - Wed, 31 Dec 2014 10:53:48 +0100</br></br>-------------------------------------- Operation with Timezone -----------------------------------------------</br>http://www.php.net/manual/en/datetime.configuration.php#ini.date.timezone </br>Timestamp - 1420019628</br>object(DateTime)#1 (3) { ["date"]=> string(26) "2014-12-31 12:53:48.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(13) "Europe/Moscow" } Timezone offset to GMT - 10800</br></br>-------------------------------------- MYSQL -----------------------------------------------</br> Notice: Use of undefined constant CURRENT_TIMESTAMP - assumed 'CURRENT_TIMESTAMP' in /in/RGLEh on line 40 INSERT INTO date_date(my_timestamp, datetime) VALUES("CURRENT_TIMESTAMP","31-12-14 12:53:48")</br> Fatal error: Uncaught Error: Call to undefined function mysql_query() in /in/RGLEh:42 Stack trace: #0 {main} thrown in /in/RGLEh on line 42
Process exited with code 255.
Output for 7.0.0 - 7.0.8
PHP INI SETTING : Europe/Amsterdam</br>Current timezone: Europe/Amsterdam</br>object(DateTime)#2 (3) { ["date"]=> string(26) "2013-11-05 10:01:34.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } </br>------------------------------------ DateTime Constants -------------------------------------------------</br>DATE_ATOM - 2013-11-05T10:01:34+01:00</br>DATE_ISO8601 - 2013-11-05T10:01:34+0100</br>DATE_RFC822 - Tue, 05 Nov 13 10:01:34 +0100</br>DATE_RSS - Tue, 05 Nov 2013 10:01:34 +0100</br></br>-------------------------------------- Operation with Date -----------------------------------------------</br>Offset to GMT - 3600</br>Date modify - Tue, 19 Nov 2013 10:01:34 +0100</br></br>-------------------------------------- Operation with Timezone -----------------------------------------------</br>http://www.php.net/manual/en/datetime.configuration.php#ini.date.timezone </br>Timestamp - 1384851694</br>object(DateTime)#1 (3) { ["date"]=> string(26) "2013-11-19 13:01:34.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(13) "Europe/Moscow" } Timezone offset to GMT - 14400</br></br>-------------------------------------- MYSQL -----------------------------------------------</br> Notice: Use of undefined constant CURRENT_TIMESTAMP - assumed 'CURRENT_TIMESTAMP' in /in/RGLEh on line 40 INSERT INTO date_date(my_timestamp, datetime) VALUES("CURRENT_TIMESTAMP","19-11-13 13:01:34")</br> Fatal error: Uncaught Error: Call to undefined function mysql_query() in /in/RGLEh:42 Stack trace: #0 {main} thrown in /in/RGLEh on line 42
Process exited with code 255.
Output for hhvm-3.12.0
PHP INI SETTING : Europe/Amsterdam</br>Current timezone: Europe/Amsterdam</br>object(DateTime)#2 (3) { ["date"]=> string(26) "2013-11-05 10:01:35.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } </br>------------------------------------ DateTime Constants -------------------------------------------------</br>DATE_ATOM - 2013-11-05T10:01:35+01:00</br>DATE_ISO8601 - 2013-11-05T10:01:35+0100</br>DATE_RFC822 - Tue, 05 Nov 13 10:01:35 +0100</br>DATE_RSS - Tue, 05 Nov 2013 10:01:35 +0100</br></br>-------------------------------------- Operation with Date -----------------------------------------------</br>Offset to GMT - 3600</br>Date modify - Tue, 19 Nov 2013 10:01:35 +0100</br></br>-------------------------------------- Operation with Timezone -----------------------------------------------</br>http://www.php.net/manual/en/datetime.configuration.php#ini.date.timezone </br>Timestamp - 1384851695</br>object(DateTime)#1 (3) { ["date"]=> string(26) "2013-11-19 13:01:35.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(13) "Europe/Moscow" } Timezone offset to GMT - 14400</br></br>-------------------------------------- MYSQL -----------------------------------------------</br> Notice: Use of undefined constant CURRENT_TIMESTAMP - assumed 'CURRENT_TIMESTAMP' in /in/RGLEh on line 40 INSERT INTO date_date(my_timestamp, datetime) VALUES("CURRENT_TIMESTAMP","19-11-13 13:01:35")</br> Warning: supplied argument is not a valid MySQL-Link resource in /in/RGLEh on line 42 Warning: supplied argument is not a valid MySQL-Link resource in /in/RGLEh on line 45 Catchable fatal error: Argument 1 passed to mysql_fetch_assoc() must be an instance of resource, bool given in /in/RGLEh on line 46
Process exited with code 255.
Output for hhvm-3.10.0
PHP INI SETTING : Europe/Amsterdam</br>Current timezone: Europe/Amsterdam</br>object(DateTime)#2 (3) { ["date"]=> string(26) "2013-11-05 10:01:34.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } </br>------------------------------------ DateTime Constants -------------------------------------------------</br>DATE_ATOM - 2013-11-05T10:01:34+01:00</br>DATE_ISO8601 - 2013-11-05T10:01:34+0100</br>DATE_RFC822 - Tue, 05 Nov 13 10:01:34 +0100</br>DATE_RSS - Tue, 05 Nov 2013 10:01:34 +0100</br></br>-------------------------------------- Operation with Date -----------------------------------------------</br>Offset to GMT - 3600</br>Date modify - Tue, 19 Nov 2013 10:01:34 +0100</br></br>-------------------------------------- Operation with Timezone -----------------------------------------------</br>http://www.php.net/manual/en/datetime.configuration.php#ini.date.timezone </br>Timestamp - 1384851694</br>object(DateTime)#1 (3) { ["date"]=> string(26) "2013-11-19 13:01:34.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(13) "Europe/Moscow" } Timezone offset to GMT - 14400</br></br>-------------------------------------- MYSQL -----------------------------------------------</br> Notice: Use of undefined constant CURRENT_TIMESTAMP - assumed 'CURRENT_TIMESTAMP' in /in/RGLEh on line 40 INSERT INTO date_date(my_timestamp, datetime) VALUES("CURRENT_TIMESTAMP","19-11-13 13:01:34")</br> Warning: supplied argument is not a valid MySQL-Link resource in /in/RGLEh on line 42 Warning: supplied argument is not a valid MySQL-Link resource in /in/RGLEh on line 45 Catchable fatal error: Argument 1 passed to mysql_fetch_assoc() must be an instance of resource, bool given in /in/RGLEh on line 46
Process exited with code 255.
Output for 5.6.28
PHP INI SETTING : Europe/Amsterdam</br>Current timezone: Europe/Amsterdam</br>object(DateTime)#2 (3) { ["date"]=> string(26) "2014-12-17 10:53:48.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } </br>------------------------------------ DateTime Constants -------------------------------------------------</br>DATE_ATOM - 2014-12-17T10:53:48+01:00</br>DATE_ISO8601 - 2014-12-17T10:53:48+0100</br>DATE_RFC822 - Wed, 17 Dec 14 10:53:48 +0100</br>DATE_RSS - Wed, 17 Dec 2014 10:53:48 +0100</br></br>-------------------------------------- Operation with Date -----------------------------------------------</br>Offset to GMT - 3600</br>Date modify - Wed, 31 Dec 2014 10:53:48 +0100</br></br>-------------------------------------- Operation with Timezone -----------------------------------------------</br>http://www.php.net/manual/en/datetime.configuration.php#ini.date.timezone </br>Timestamp - 1420019628</br>object(DateTime)#1 (3) { ["date"]=> string(26) "2014-12-31 12:53:48.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(13) "Europe/Moscow" } Timezone offset to GMT - 10800</br></br>-------------------------------------- MYSQL -----------------------------------------------</br> Notice: Use of undefined constant CURRENT_TIMESTAMP - assumed 'CURRENT_TIMESTAMP' in /in/RGLEh on line 40 INSERT INTO date_date(my_timestamp, datetime) VALUES("CURRENT_TIMESTAMP","31-12-14 12:53:48")</br> Fatal error: Call to undefined function mysql_query() in /in/RGLEh on line 42
Process exited with code 255.
Output for 5.4.30 - 5.4.45, 5.5.14 - 5.6.23
PHP INI SETTING : Europe/Amsterdam</br>Current timezone: Europe/Amsterdam</br>object(DateTime)#2 (3) { ["date"]=> string(26) "2013-11-05 10:01:34.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } </br>------------------------------------ DateTime Constants -------------------------------------------------</br>DATE_ATOM - 2013-11-05T10:01:34+01:00</br>DATE_ISO8601 - 2013-11-05T10:01:34+0100</br>DATE_RFC822 - Tue, 05 Nov 13 10:01:34 +0100</br>DATE_RSS - Tue, 05 Nov 2013 10:01:34 +0100</br></br>-------------------------------------- Operation with Date -----------------------------------------------</br>Offset to GMT - 3600</br>Date modify - Tue, 19 Nov 2013 10:01:34 +0100</br></br>-------------------------------------- Operation with Timezone -----------------------------------------------</br>http://www.php.net/manual/en/datetime.configuration.php#ini.date.timezone </br>Timestamp - 1384851694</br>object(DateTime)#1 (3) { ["date"]=> string(26) "2013-11-19 13:01:34.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(13) "Europe/Moscow" } Timezone offset to GMT - 14400</br></br>-------------------------------------- MYSQL -----------------------------------------------</br> Notice: Use of undefined constant CURRENT_TIMESTAMP - assumed 'CURRENT_TIMESTAMP' in /in/RGLEh on line 40 INSERT INTO date_date(my_timestamp, datetime) VALUES("CURRENT_TIMESTAMP","19-11-13 13:01:34")</br> Fatal error: Call to undefined function mysql_query() in /in/RGLEh on line 42
Process exited with code 255.
Output for 5.3.7 - 5.4.29, 5.5.0 - 5.5.13
PHP INI SETTING : Europe/Amsterdam</br>Current timezone: Europe/Amsterdam</br>object(DateTime)#2 (3) { ["date"]=> string(19) "2013-11-05 10:01:34" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } </br>------------------------------------ DateTime Constants -------------------------------------------------</br>DATE_ATOM - 2013-11-05T10:01:34+01:00</br>DATE_ISO8601 - 2013-11-05T10:01:34+0100</br>DATE_RFC822 - Tue, 05 Nov 13 10:01:34 +0100</br>DATE_RSS - Tue, 05 Nov 2013 10:01:34 +0100</br></br>-------------------------------------- Operation with Date -----------------------------------------------</br>Offset to GMT - 3600</br>Date modify - Tue, 19 Nov 2013 10:01:34 +0100</br></br>-------------------------------------- Operation with Timezone -----------------------------------------------</br>http://www.php.net/manual/en/datetime.configuration.php#ini.date.timezone </br>Timestamp - 1384851694</br>object(DateTime)#1 (3) { ["date"]=> string(19) "2013-11-19 13:01:34" ["timezone_type"]=> int(3) ["timezone"]=> string(13) "Europe/Moscow" } Timezone offset to GMT - 14400</br></br>-------------------------------------- MYSQL -----------------------------------------------</br> Notice: Use of undefined constant CURRENT_TIMESTAMP - assumed 'CURRENT_TIMESTAMP' in /in/RGLEh on line 40 INSERT INTO date_date(my_timestamp, datetime) VALUES("CURRENT_TIMESTAMP","19-11-13 13:01:34")</br> Fatal error: Call to undefined function mysql_query() in /in/RGLEh on line 42
Process exited with code 255.
Output for 5.3.0 - 5.3.6
PHP INI SETTING : Europe/Amsterdam</br>Current timezone: Europe/Amsterdam</br>object(DateTime)#2 (3) { ["date"]=> string(19) "2013-11-05 10:01:34" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } </br>------------------------------------ DateTime Constants -------------------------------------------------</br>DATE_ATOM - 2013-11-05T10:01:34+01:00</br>DATE_ISO8601 - 2013-11-05T10:01:34+0100</br>DATE_RFC822 - Tue, 05 Nov 13 10:01:34 +0100</br>DATE_RSS - Tue, 05 Nov 2013 10:01:34 +0100</br></br>-------------------------------------- Operation with Date -----------------------------------------------</br>Offset to GMT - 3600</br>Date modify - Tue, 19 Nov 2013 10:01:34 +0100</br></br>-------------------------------------- Operation with Timezone -----------------------------------------------</br>http://www.php.net/manual/en/datetime.configuration.php#ini.date.timezone </br>Timestamp - 1384851694</br>object(DateTime)#1 (3) { ["date"]=> string(19) "2013-11-19 12:01:34" ["timezone_type"]=> int(3) ["timezone"]=> string(13) "Europe/Moscow" } Timezone offset to GMT - 10800</br></br>-------------------------------------- MYSQL -----------------------------------------------</br> Notice: Use of undefined constant CURRENT_TIMESTAMP - assumed 'CURRENT_TIMESTAMP' in /in/RGLEh on line 40 INSERT INTO date_date(my_timestamp, datetime) VALUES("CURRENT_TIMESTAMP","19-11-13 12:01:34")</br> Fatal error: Call to undefined function mysql_query() in /in/RGLEh on line 42
Process exited with code 255.
Output for 5.2.0 - 5.2.17
PHP INI SETTING : Europe/Amsterdam</br>Current timezone: Europe/Amsterdam</br>object(DateTime)#2 (0) { } </br>------------------------------------ DateTime Constants -------------------------------------------------</br>DATE_ATOM - 2013-11-05T10:01:34+01:00</br>DATE_ISO8601 - 2013-11-05T10:01:34+0100</br>DATE_RFC822 - Tue, 05 Nov 13 10:01:34 +0100</br>DATE_RSS - Tue, 05 Nov 2013 10:01:34 +0100</br></br>-------------------------------------- Operation with Date -----------------------------------------------</br>Offset to GMT - 3600</br> Fatal error: Call to a member function format() on a non-object in /in/RGLEh on line 22
Process exited with code 255.
Output for 5.1.0 - 5.1.6
PHP INI SETTING : Europe/Amsterdam</br>Current timezone: Europe/Amsterdam</br> Fatal error: Class 'DateTime' not found in /in/RGLEh on line 11
Process exited with code 255.
Output for 5.0.0 - 5.0.5
PHP INI SETTING : </br> Fatal error: Call to undefined function date_default_timezone_get() in /in/RGLEh on line 10
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_OBJECT_OPERATOR, expecting ',' or ';' in /in/RGLEh on line 22
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_OBJECT_OPERATOR, expecting ',' or ';' in /in/RGLEh on line 22
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `','' or `';'' in /in/RGLEh on line 22
Process exited with code 255.