Archive for the ‘ Uncategorized ’ Category

Converting Unixtime to Milliseconds

My friend was struggling with getting the milliseconds of a unix time stamp in PHP, so thought i’d post some ideas here, see if they help people!

To get NOW in milliseconds:
microtime() – http://uk2.php.net/microtime

Otherwise you’ll need to do the following

$mseconds = date(“u”, $timestamp);

You’ll need PHP 5.2.2 to do it.

Or on earlier versions of PHP i’m sure you could just do $ms = $unixtime * 1000; – you’re not going to be able to populate the last few digits as you don’t have that information in a unixtime stamp.

Hope this helps!