1

我有一个下面的 JavaScript 函数,它timefull date.

function f() {
  var monthNames = ["Jan", "Feb", "Mar", "Apr", "May", "Jun",
    "Jul", "Aug", "Sept", "Oct", "Nov", "Dec"
  ];
  d = new Date();
  var utcOffset = -6;
  var utc = d.getTime() + (d.getTimezoneOffset() * 60000);
  var localDate = new Date(utc + (3600000 * (utcOffset + 1)));
  var fullDate = localDate.getDate() + ' ' + monthNames[localDate.getMonth()] + ' ' + localDate.getFullYear() + ' ' + localDate.toLocaleTimeString();
  var now = new Date(fullDate).getTime();
  return now;
}

在所有浏览器中,它都会返回预期的输出,但对于 Internet Explorer 11,它不会返回,因为它返回NaN.

请提出更改以获得预期的输出。

4

0 回答 0