我从 SQL Server 返回一个整数时间戳(1970 年 1 月 1 日之后的秒数)。我遇到的问题是dojo(或javascript)假设时间戳是GMT,然后将其转换为我的本地时区。有没有办法在我创建新日期时设置时区,或者告诉dojo不要进行转换?这是我的代码
function formatDate(value) {
// SQL Server returns seconds -- multiply by 1000 to get milliseconds
var date = new Date(parseInt(value) * 1000);
return ddl.format(date, {//ddl is dojo/date/local
selector: "date",
datePattern: 'MM/dd/yyyy h:m a'
});
}
由于标准时间和夏令时,我真的不想在时间戳中添加时间
谢谢
最佳答案
我在这里找到了答案:
How do you create a JavaScript Date object with a set timezone without using a string representation
var d = new Date(xiYear, xiMonth, xiDate);
d.setTime( d.getTime() + d.getTimezoneOffset()*60*1000 );
关于javascript - 道场中的时间戳日期时区问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24662476/