var d = new Date()
var datestr = "今天是: " +d.getFullYear() + "-" +(d.getMonth()+1) + "-" + d.getDate() + " " + d.getHours() + ":" + d.getMinutes() + ":" + d.getSeconds() + " 星期"+"日一二三四五六".charAt(d.getDay())
// 判断闰年
Date.prototype.isLeapYear = function()
{
return (0==this.getYear()%4&&((this.getYear()%100!=0)||(this.getYear()%400==0)))
}
// 日期格式化
// 格式 YYYY/yyyy/YY/yy 表示年份
// MM/M 月份
// W/w 星期
// dd/DD/d/D 日期
// hh/HH/h/H 时间
// mm/m 分钟
// ss/SS/s/S 秒
//---------------------------------------------------
Date.prototype.Format = function(formatStr)
{
var str = formatStr
var Week = ['日','一','二','三','四','五','六']
str=str.replace(/yyyy|YYYY/,this.getFullYear())
str=str.replace(/yy|YY/,(this.getYear() % 100)>9 (this.getYear() % 100).toString():'0' + (this.getYear() % 100))
.......
function getPreviousWeekStartEnd(date){var date = new Date() || date, day, start, end, dayMSec = 24 * 3600 * 1000
today = date.getDay() - 1
end = date.getTime() - today * dayMSec
start = end - 7 * dayMSec
return {start : getFormatTime(start), end : getFormatTime(end)}
function getFormatTime(time){
date.setTime(time)
return date.getFullYear() + '-' + ('0' + (date.getMonth() + 1)).slice(-2) + '-' + ('0' + date.getDate()).slice(-2) + ' 00:00:00'
}
}
//方法调用var d = getPreviousWeekStartEnd()
d.start为开始,d.end为结束