如何从JavaScript中的时间戳获取星期几? 我想从我指定的时间戳中获取此信息,而不是当前日期。
由于
答案 0 :(得分:15)
var timestamp = 1400000000;
var a = new Date(timestamp*1000);
var days = ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'];
var dayOfWeek = days[a.getDay()]
现在“星期几”是dayOfWeek变量。
答案 1 :(得分:6)
var timestamp = 654524560; // UNIX timestamp in seconds
var xx = new Date();
xx.setTime(timestamp*1000); // javascript timestamps are in milliseconds
document.write(xx.toUTCString());
document.write(xx.getDay()); // the Day
答案 2 :(得分:-1)
尝试以下内容:
var currentTime = new Date();
var day = currentTime.getDate();