输出格式:

星期四 3月4日 2020年

代码:

假设输出到.current-date这个div中。

function currentDate() {
	$container = $('.current-date');
	if ($container.length) {
		var now = new Date($.ajax({ async: false }).getResponseHeader('Date'));
		var month = now.getMonth() + 1;
		var day = now.getDate();
		var week = now.getDay();
		if (week == 0) {
			wstr = '星期日';
		} else if (week == 1) {
			wstr = '星期一';
		} else if (week == 2) {
			wstr = '星期二';
		} else if (week == 3) {
			wstr = '星期三';
		} else if (week == 4) {
			wstr = '星期四';
		} else if (week == 5) {
			wstr = '星期五';
		} else if (week == 6) {
			wstr = '星期六';
		}
		week = wstr;
		$container.html(week + ' ' + month + '月' + day + '日' + ' ' + now.getFullYear() + '年');
	}
}
$(function() {
	currentDate();
});