Created
April 16, 2013 13:02
-
-
Save calvinchoy/5395707 to your computer and use it in GitHub Desktop.
PHP - Date with with ms
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 | |
function udate($format, $utimestamp = null) { | |
if (is_null($utimestamp)) | |
$utimestamp = microtime(true); | |
$timestamp = floor($utimestamp); | |
$milliseconds = round(($utimestamp - $timestamp) * 1000000); | |
return date(preg_replace('`(?<!\\\\)u`', $milliseconds, $format), $timestamp); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment