-
-
Save vreemt/b078a63fbdf8416d10d14337dca724cb to your computer and use it in GitHub Desktop.
php datetime
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$datetime = [ | |
['May 11, 2023', 'Europe/London'], | |
['June 1, 2023', 'Europe/London'], | |
]; | |
echo "<pre>"; $out = ""; | |
foreach ($datetime as $dateinfo) { | |
echo PHP_EOL; | |
echo implode(" ", $dateinfo); | |
echo PHP_EOL; | |
try { | |
$dt = date_create_from_format( | |
"F j, Y", $dateinfo[0], | |
new DateTimeZone($dateinfo[1]) | |
); | |
//var_dump($dt); | |
if ($dt) { | |
echo $dt->format('T'); | |
} | |
} catch(Exception $e) { | |
echo $e->getMessage(); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
on May 11, 2023
http://phptester.net/ php 8.1