- var_dump: documentation ( source)
<?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);
}