function getDateStr1() {
var date = new Date();
var y = date.getFullYear();
var m = date.getMonth() + 1;
var d = date.getDate();
var h = date.getHours();
var mi = date.getMinutes();
// return y + "-" + m + "-" + d + " " + h + ":00";// + mi;
return y + "-" + m + "-" + d + " 06:00"; // + mi;
}
function getDateStr2() {
var date = new Date();
var y = date.getFullYear();
var m = date.getMonth() + 1;
var d = date.getDate();
var h = date.getHours();
var mi = date.getMinutes();
// return y + "-" + m + "-" + d + " " + h + ":00";// + mi;
return y + "-" + m + "-" + d + " 18:00"; // + mi;
}
function ww4(date) {
var y = date.getFullYear();
var m = date.getMonth() + 1;
var d = date.getDate();
var h = date.getHours();
var mi = date.getMinutes();
return y + '-' + (m < 10 ? ('0' + m) : m) + '-' + (d < 10 ? ('0' + d) : d) + ' ' + (h < 10 ? ('0' + h) : h) + ':' + (mi < 10 ? ('0' + mi) : mi);
}
function w4(s) {
debugger;
var aaa = (s.split(" "));
var mm = (aaa[0].split("-"));
var y = parseInt(mm[0], 10);
var m = parseInt(mm[1], 10);
var d = parseInt(mm[2], 10);
var nn = (aaa[1].split(":"));
var h = parseInt(nn[0], 10);
var mi = parseInt(nn[1], 10);
if (!isNaN(y) && !isNaN(m) && !isNaN(d) && !isNaN(h) && !isNaN(mi)) {
var aa = new Date(y, m - 1, d, h, mi);
return aa;
} else {
return new Date();
}
}
function myformatter(date) {
var y = date.getFullYear();
var m = date.getMonth() + 1;
var d = date.getDate();
return y + '-' + (m < 10 ? ('0' + m) : m) + '-' + (d < 10 ? ('0' + d) : d);
}
function myparser(s) {
if (!s) return new Date();
var ss = (s.split('-'));
var y = parseInt(ss[0], 10);
var m = parseInt(ss[1], 10);
var d = parseInt(ss[2], 10);
if (!isNaN(y) && !isNaN(m) && !isNaN(d)) {
return new Date(y, m - 1, d);
} else {
return new Date();
}
}
function toDate(str) {
var sd = str.split("-");
return new Date(sd[0], sd[1], sd[2]);
}
//interval :D表示查询精确到天数的之差
//interval :H表示查询精确到小时之差
//interval :M表示查询精确到分钟之差
//interval :S表示查询精确到秒之差
//interval :T表示查询精确到毫秒之差
//使用方法: alert(dateDiff('D', '2007-4-1', '2007/04/19'));
function dateDiff(interval, date1, date2) {
var objInterval = { 'D': 1000 * 60 * 60 * 24, 'H': 1000 * 60 * 60, 'M': 1000 * 60, 'S': 1000, 'T': 1 };
interval = interval.toUpperCase();
var dt1 = new Date(Date.parse(date1.replace(/-/g, '/')));
var dt2 = new Date(Date.parse(date2.replace(/-/g, '/')));
try {
return Math.round((dt2.getTime() - dt1.getTime()) / eval('objInterval.' + interval));
}
catch (e) {
return e.message;
}
}
//日期比较(yyyy-mm-dd)
// 返回值: -1 表示 time1 大于 time2
// 1 表示 time1 小于 time2
// 0 表示 time1 等于 time2
function compareDate(time1, time2) {
var arr = time1.split("-");
var starttime = new Date(arr[0], arr[1], arr[2]);
var starttimes = starttime.getTime();
var arrs = time2.split("-");
var endtime = new Date(arrs[0], arrs[1], arrs[2]);
var endtimes = endtime.getTime();
if (starttimes > endtimes) {//alert('time1 大于 time2');
return '-1';
}else if (starttimes == endtimes){
return '0';
}else if(starttimes < endtimes){
return '1';
}
}
function compareTime(beginTime, endTime) {
var beginTimes = beginTime.substring(0, 10).split('-');
var endTimes = endTime.substring(0, 10).split('-');
beginTime = beginTimes[1] + '-' + beginTimes[2] + '-' + beginTimes[0] + ' ' + beginTime.substring(10, 19);
endTime = endTimes[1] + '-' + endTimes[2] + '-' + endTimes[0] + ' ' + endTime.substring(10, 19);
var a = (Date.parse(endTime) - Date.parse(beginTime)) / 3600 / 1000;
if (a < 0) {
return '-1';
} else if (a > 0) {
return '1'; // alert("endTime大!");
} else if (a == 0) {
return '0';
}
}