var today = new Date();
var hongkong = new Date(1997, 6, 1, 14, 0, 1);
console.log(hongkong);//1997-07-01 T 06:00:01.000Z
console.log(hongkong.getFullYear());// 年份
console.log(hongkong.getMonth());// 月份从0开始
console.log(hongkong.getDate());// 天//day
console.log(hongkong.getHours());// 小时
console.log(hongkong.getMinutes());// 分钟
console.log(hongkong.getSeconds());// 秒数
console.log(hongkong.getDay());// 星期数
var mySecond = today.getTime();
mySecond += 24 * 60 * 60 * 1000;
var future40 = new Date(mySecond);
console.log(“星期” + future40.getDay());
JS获取当前年月日
最新推荐文章于 2024-03-31 09:44:29 发布