I got a string that represents seconds (e.g value is "14.76580"). I want to set a new variable that has the value of the decimal portion (milliseconds) of that string ( e.g x = 76580 ) and I'm not sure what's the best way to do that. May you help please ?
You can use this function to calculate the ms portion from a time (works on strings too):
function getMilliSeconds(num)
{
return (num % 1) * 1000;
}
getMilliSeconds(1.123); // 123
getMilliSeconds(14.76580); // 765.8000000000005
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With