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
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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.