dsaba Posted August 27, 2007 Share Posted August 27, 2007 Hi! I am trying to mimic the Javascript new Date().getTime(); function with php and retrieve # of milliseconds since 1970 php's time() function however calculates # of seconds not milliseconds since 1970 I tried multipying by 1 million but then the timestamp turns into 12342434 E + 3243.... It makes it into E's... So basically how can I mathematically make this string: PHP timestamp: 1188186747 equal to this string: Javascript timestamp: 1188186747328 and without the annoying "E's" Thank you Link to comment https://forums.phpfreaks.com/topic/66822-convert-seconds-to-milliseconds/ Share on other sites More sharing options...
pocobueno1388 Posted August 27, 2007 Share Posted August 27, 2007 You need to use BCMath for large numbers. http://www.php.net/manual/en/ref.bc.php Link to comment https://forums.phpfreaks.com/topic/66822-convert-seconds-to-milliseconds/#findComment-334998 Share on other sites More sharing options...
dsaba Posted August 27, 2007 Author Share Posted August 27, 2007 dunno I looked it up and it helps show the numbers without the E's but I still have my math wrong, its late.. no sleep who knows someone help me out.. how do I convert it? $timeStamp = bcdiv($timeStamp, .0001); i tried bcmul, bcdiv can't seem to get it i mean there are 1 million milliseconds in 1 second so i multiply by a million but this just adds more 00s to the end, it doesnt get the extra 3 digits at the end still..... maybe I can use micro time somehow? i can subtract microtime of now - 1970 ?? what is the microtime of 1970? Link to comment https://forums.phpfreaks.com/topic/66822-convert-seconds-to-milliseconds/#findComment-335004 Share on other sites More sharing options...
Psycho Posted August 27, 2007 Share Posted August 27, 2007 i mean there are 1 million milliseconds in 1 second so i multiply by a million but this just adds more 00s to the end, it doesnt get the extra 3 digits at the end still..... No. A millisecond is 1/1,000 (one-thousandth) of a second. Link to comment https://forums.phpfreaks.com/topic/66822-convert-seconds-to-milliseconds/#findComment-335024 Share on other sites More sharing options...
Barand Posted August 27, 2007 Share Posted August 27, 2007 http://www.php.net/microtime Link to comment https://forums.phpfreaks.com/topic/66822-convert-seconds-to-milliseconds/#findComment-335061 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.