我试图解释一系列代表时间的数字,以便在不久的将来将它们更改为不同的数字。135671800有多长?每一个都意味着什么?是DD:HH:MM:SS吗?
{"next_timestamp":1356751800,"next_duration":9000,"next_title":"Saturday Night","next_description":"Hearing and Healing"}解释结果的原始javascript是:
else if (typeof data.next_timestamp !== "undefined") {
seconds_till = data.next_timestamp - (new Date().getTime() / 1000);
days = Math.floor((seconds_till % 31536000) / 86400);
hours = Math.floor((seconds_till % 86400) / 3600);
minutes = Math.floor((seconds_till % 3600) / 60);
seconds = Math.floor(seconds_till % 60);
return intervalId = setInterval(function() {
if (--seconds < 0) {
seconds = 59;
if (--minutes < 0) {
minutes = 59;
if (--hours < 0) {
hours = 23;
if (--days < 0) {
days = 365;
}
}
}
}谢谢!
发布于 2012-12-29 00:04:50
如果您使用的是标准时间戳,则只需使用Javascript Date对象即可。
var date = new Date(/* timestamp * 1000 here */);
var day = date.getDay();
var month = date.getMonth();
var year = date.getFullYear();不知道你的间隔是什么,但如果你想把这个数回到0.
// Assume that date still exists.
time = date.getTime() / 1000;
time--;
date = new Date(time * 1000);
day = date.getDay();
month = date.getMonth();
year = date.getFullYear();发布于 2012-12-28 23:49:16
这是从“时代”(自1970年1月1日午夜协调世界时(UTC)以来已经过去的秒)。实际日期:2012年12月29日格林尼治时间03:30
见这里的实时计数器http://www.epochconverter.com/
关于UNIX time的更多信息
https://stackoverflow.com/questions/14077176
复制相似问题