JSON在线解析

提问人:SOJSON用户 提问日期:2017-03-27 00:00 热度:138
问题标签 js Jquery

通过JS/Javascript/Jquery 获取当前年月日星期。

1条回答 我来回答
soゝso| 2017-03-27 00:01
$("#now").click(function () {
	var date = new Date();
	this.year = date.getFullYear();
	this.month = date.getMonth() + 1;
	this.date = date.getDate();
	this.day = new Array("星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六")[date.getDay()];
	this.hour = date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
	this.minute = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
	this.second = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
	var currentTime = "现在是:" + this.year + "年" + this.month + "月" + this.date + "日 " + this.hour + ":" + this.minute + ":" + this.second + " " + this.day;
	alert(currentTime);
});

试着把上面输出一下。通过Javascript获取到当前日期!