Skip to content

Instantly share code, notes, and snippets.

@calvinchoy
Created April 16, 2013 13:02
Show Gist options
  • Save calvinchoy/5395707 to your computer and use it in GitHub Desktop.
Save calvinchoy/5395707 to your computer and use it in GitHub Desktop.
PHP - Date with with ms
<?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