Created
October 24, 2020 20:40
-
-
Save piotr-zuralski/0c82bcdfd9130d058f5311ce85199109 to your computer and use it in GitHub Desktop.
PHP DateTime with mictotime
This file contains 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 | |
declare(strict_types=1); | |
$t = explode(' ', microtime()); | |
$dateTime = DateTime::createFromFormat('U.u', | |
$t[1] . substr($t[0], 1, 7) | |
); | |
$dateTime->setTimeZone( | |
new DateTimeZone( | |
date_default_timezone_get() ?: 'UTC' | |
) | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment