Created
June 20, 2013 08:37
-
-
Save calvinchoy/5821185 to your computer and use it in GitHub Desktop.
PHP - udate, transform date in micro format
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