javascript getTime()仅限于10位数字 [英] javascript getTime() to 10 digits only
本文介绍了javascript getTime()仅限于10位数字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用以下函数来使用javascript获取时间:
I am using the following function to get the Time using javascript:
function timeMil(){
var date = new Date();
var timeMil = date.getTime();
return timeMil;
}
我得到的值是:
1352162391299
1352162391299
在PHP中,我使用 time();
函数获取Time,而我得到的值是
While in PHP, I use the time();
function to get Time and the value I get is
1352162391
如何转换javascript时间的值以删除最后3位数字,并使其仅10位数字.
How do I convert the value of javascript time to remove the last 3 digits and make it 10 digits only.
从1352162391299
到 1352162391
因此Javascript时间与PHP时间相同.
From 1352162391299
To 1352162391
So that the Javascript time is the same with the PHP time.
推荐答案
我认为您只需将其除以1000毫秒,就可以在几秒钟内获得时间
I think you just have to divide it by 1000 milliseconds and you'll get time in seconds
Math.floor(date.getTime()/1000)
这篇关于javascript getTime()仅限于10位数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文