NodeJS 在浏览器窗口中使用javascript日期格式返回wday,day,mon. and yr

ecfsfe2w  于 2023-01-25  发布在  Node.js
关注(0)|答案(1)|浏览(82)
var today = new Date();

var dateOptions = {
    weekday:"long",
    day: "numeric",
    month: "long",
    year: "numeric"
  };
 var day = today.toLocaleDateString("en-US", dateOptions);

返回空窗口,什么也不显示

oxcyiej7

oxcyiej71#

你什么意思?你可以用

var date = new Date().toUTCString()
var hour = new Date().getUTCHours()
var day = new Date().getUTCDate()
var month = new Date().getUTCMonth()
var year = new Date().getUTCFullYear()
var mstime = new Date().getUTCMilliseconds()
console.log(date)
console.log(hour)
console.log(day)
console.log(month)
console.log(year)
console.log(mstime)
//! expected output
Date : Sun, 23 Oct 2022 17:49:20 GMT
Hour : 17
Day : 23
Month : 9
Year : 2022
Get a time but in ms : 1666547360034

相关问题