Jump to content

convert seconds to milliseconds


dsaba

Recommended Posts

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

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?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.