Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
126
rated 0 times [  131] [ 5]  / answers: 1 / hits: 26909  / 12 Years ago, tue, november 6, 2012, 12:00:00

I am using the following function to get the Time using javascript:



function timeMil(){
var date = new Date();
var timeMil = date.getTime();

return timeMil;
}


And the value I get is:




1352162391299




While in PHP, I use the time(); function to get Time and the value I get is



1352162391


How do I convert the value of javascript time to remove the last 3 digits and make it 10 digits only.




From 1352162391299
To     1352162391

So that the Javascript time is the same with the PHP time.



More From » datetime

 Answers
5

I think you just have to divide it by 1000 milliseconds and you'll get time in seconds



Math.floor(date.getTime()/1000)

[#82170] Monday, November 5, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
dayana

Total Points: 302
Total Questions: 102
Total Answers: 100

Location: Cayman Islands
Member since Fri, Mar 4, 2022
2 Years ago
;