/**************时间戳转时间格式*****************/
function getMyDate(str){
var oDate = new Date(str),
oYear = oDate.getFullYear(),
oMonth = oDate.getMonth()+1,
oDay = oDate.getDate(),
oHour = oDate.getHours(),
oMin = oDate.getMinutes(),
oSen = oDate.getSeconds(),
oTime = oYear +'-'+ getzf(oMonth) +'-'+ getzf(oDay) +' '+ getzf(oHour) +':'+ getzf(oMin) +':'+getzf(oSen);//最后拼接时间
return oTime;
};
function getzf(num){
if(parseInt(num) < 10){
num = '0'+num;
}
return num;
}
/**************时间戳转时间格式end*****************/
/*************格式化日期(yyyy-MM-dd)****************/
function FormatDate (strTime) {
var date = new Date(strTime);
var mon = date.getMonth()+1;
var day = date.getDate();
if(mon<9){
mon = "0"+""+mon;
}
if(day<9){
day = "0"+""+day;
}
return date.getFullYear()+"-"+mon+"-"+day;
}
/*******************得到每周的第一天(周日)***********************/
function getFirstDateOfWeek(theDate){
var firstDateOfWeek;
theDate = new Date(theDate);
theDate.setDate(theDate.getDate() - theDate.getDay());
firstDateOfWeek = theDate;
return firstDateOfWeek;
}
/*******************得到每周的最后一天(周六)*********************/
function getLastDateOfWeek(theDate){
var lastDateOfWeek;
theDate = new Date(theDate);
theDate.setDate(theDate.getDate() + 6 - theDate.getDay());
lastDateOfWeek = theDate;
return lastDateOfWeek;
}
/*******************获取所选日期所在月份第一天************************/
function getFirstDayOfMonth(theDate){
var startdate=new Date(theDate);
startdate.setDate(1);
return startdate;
}
/***************获取选择日期所在月最后一天*******************/
function getLastDayOfMonth(theDate){
var endDate = new Date(theDate);
var month=endDate.getMonth();
var nextMonth=++month;
var nextMonthFirstDay=new Date(endDate.getFullYear(),nextMonth,1);
var oneDay=1000*60*60*24;
return new Date(nextMonthFirstDay-oneDay);
}
function getMyDate(str){
var oDate = new Date(str),
oYear = oDate.getFullYear(),
oMonth = oDate.getMonth()+1,
oDay = oDate.getDate(),
oHour = oDate.getHours(),
oMin = oDate.getMinutes(),
oSen = oDate.getSeconds(),
oTime = oYear +'-'+ getzf(oMonth) +'-'+ getzf(oDay) +' '+ getzf(oHour) +':'+ getzf(oMin) +':'+getzf(oSen);//最后拼接时间
return oTime;
};
function getzf(num){
if(parseInt(num) < 10){
num = '0'+num;
}
return num;
}
/**************时间戳转时间格式end*****************/
/*************格式化日期(yyyy-MM-dd)****************/
function FormatDate (strTime) {
var date = new Date(strTime);
var mon = date.getMonth()+1;
var day = date.getDate();
if(mon<9){
mon = "0"+""+mon;
}
if(day<9){
day = "0"+""+day;
}
return date.getFullYear()+"-"+mon+"-"+day;
}
/*******************得到每周的第一天(周日)***********************/
function getFirstDateOfWeek(theDate){
var firstDateOfWeek;
theDate = new Date(theDate);
theDate.setDate(theDate.getDate() - theDate.getDay());
firstDateOfWeek = theDate;
return firstDateOfWeek;
}
/*******************得到每周的最后一天(周六)*********************/
function getLastDateOfWeek(theDate){
var lastDateOfWeek;
theDate = new Date(theDate);
theDate.setDate(theDate.getDate() + 6 - theDate.getDay());
lastDateOfWeek = theDate;
return lastDateOfWeek;
}
/*******************获取所选日期所在月份第一天************************/
function getFirstDayOfMonth(theDate){
var startdate=new Date(theDate);
startdate.setDate(1);
return startdate;
}
/***************获取选择日期所在月最后一天*******************/
function getLastDayOfMonth(theDate){
var endDate = new Date(theDate);
var month=endDate.getMonth();
var nextMonth=++month;
var nextMonthFirstDay=new Date(endDate.getFullYear(),nextMonth,1);
var oneDay=1000*60*60*24;
return new Date(nextMonthFirstDay-oneDay);
}