3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getFormattedDateTime($date, $timezone) { $datetime = DateTimeImmutable::createFromFormat( 'Y-m-d H:i:s', $date, new DateTimeZone( $timezone ) ); $rfc3339 = $datetime->format( DATE_RFC3339 ); var_dump($rfc3339); } $timezones = [ 'UTC', 'America/Regina', 'Europe/Kiev', ]; $date = '1970-01-01 00:00:00'; foreach ($timezones as $timezone) { getFormattedDateTime($date, $timezone); } $date = '2022-08-29 12:00:00'; foreach ($timezones as $timezone) { getFormattedDateTime($date, $timezone); }

preferences:
74.4 ms | 404 KiB | 5 Q