3v4l.org

run code in 300+ PHP versions simultaneously
<?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.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Fatal error: Uncaught Error: Call to undefined function mysql_connect() in /in/YuXpc:2 Stack trace: #0 {main} thrown in /in/YuXpc on line 2
Process exited with code 255.
Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40
Fatal error: Call to undefined function mysql_connect() in /in/YuXpc on line 2
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/YuXpc on line 22
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1
Parse error: parse error, unexpected T_OBJECT_OPERATOR, expecting ',' or ';' in /in/YuXpc on line 22
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `','' or `';'' in /in/YuXpc on line 22
Process exited with code 255.

preferences:
271.48 ms | 401 KiB | 460 Q