无为清净楼资源网 Design By www.qnjia.com
复制代码 代码如下:
var TimeObjectUtil;
/**
* @title 时间工具类
* @note 本类一律违规验证返回false
* @author {boonyachengdu@gmail.com}
* @date 2013-07-01
* @formatter "2013-07-01 00:00:00" , "2013-07-01"
*/
TimeObjectUtil = {
/**
* 获取当前时间毫秒数
*/
getCurrentMsTime : function() {
var myDate = new Date();
return myDate.getTime();
},
/**
* 毫秒转时间格式
*/
longMsTimeConvertToDateTime : function(time) {
var myDate = new Date(time);
return this.formatterDateTime(myDate);
},
/**
* 时间格式转毫秒
*/
dateToLongMsTime : function(date) {
var myDate = new Date(date);
return myDate.getTime();
},
/**
* 格式化日期(不含时间)
*/
formatterDate : function(date) {
var datetime = date.getFullYear()
+ "-"// "年"
+ ((date.getMonth() + 1) > 10 ? (date.getMonth() + 1) : "0"
+ (date.getMonth() + 1))
+ "-"// "月"
+ (date.getDate() < 10 ? "0" + date.getDate() : date
.getDate());
return datetime;
},
/**
* 格式化日期(含时间"00:00:00")
*/
formatterDate2 : function(date) {
var datetime = date.getFullYear()
+ "-"// "年"
+ ((date.getMonth() + 1) > 10 ? (date.getMonth() + 1) : "0"
+ (date.getMonth() + 1))
+ "-"// "月"
+ (date.getDate() < 10 ? "0" + date.getDate() : date
.getDate()) + " " + "00:00:00";
return datetime;
},
/**
* 格式化去日期(含时间)
*/
formatterDateTime : function(date) {
var datetime = date.getFullYear()
+ "-"// "年"
+ ((date.getMonth() + 1) > 10 ? (date.getMonth() + 1) : "0"
+ (date.getMonth() + 1))
+ "-"// "月"
+ (date.getDate() < 10 ? "0" + date.getDate() : date
.getDate())
+ " "
+ (date.getHours() < 10 ? "0" + date.getHours() : date
.getHours())
+ ":"
+ (date.getMinutes() < 10 ? "0" + date.getMinutes() : date
.getMinutes())
+ ":"
+ (date.getSeconds() < 10 ? "0" + date.getSeconds() : date
.getSeconds());
return datetime;
},
/**
* 时间比较{结束时间大于开始时间}
*/
compareDateEndTimeGTStartTime : function(startTime, endTime) {
return ((new Date(endTime.replace(/-/g, "/"))) > (new Date(
startTime.replace(/-/g, "/"))));
},
/**
* 验证开始时间合理性{开始时间不能小于当前时间{X}个月}
*/
compareRightStartTime : function(month, startTime) {
var now = formatterDayAndTime(new Date());
var sms = new Date(startTime.replace(/-/g, "/"));
var ems = new Date(now.replace(/-/g, "/"));
var tDayms = month * 30 * 24 * 60 * 60 * 1000;
var dvalue = ems - sms;
if (dvalue > tDayms) {
return false;
}
return true;
},
/**
* 验证开始时间合理性{结束时间不能小于当前时间{X}个月}
*/
compareRightEndTime : function(month, endTime) {
var now = formatterDayAndTime(new Date());
var sms = new Date(now.replace(/-/g, "/"));
var ems = new Date(endTime.replace(/-/g, "/"));
var tDayms = month * 30 * 24 * 60 * 60 * 1000;
var dvalue = sms - ems;
if (dvalue > tDayms) {
return false;
}
return true;
},
/**
* 验证开始时间合理性{结束时间与开始时间的间隔不能大于{X}个月}
*/
compareEndTimeGTStartTime : function(month, startTime, endTime) {
var sms = new Date(startTime.replace(/-/g, "/"));
var ems = new Date(endTime.replace(/-/g, "/"));
var tDayms = month * 30 * 24 * 60 * 60 * 1000;
var dvalue = ems - sms;
if (dvalue > tDayms) {
return false;
}
return true;
},
/**
* 获取最近几天[开始时间和结束时间值,时间往前推算]
*/
getRecentDaysDateTime : function(day) {
var daymsTime = day * 24 * 60 * 60 * 1000;
var yesterDatsmsTime = this.getCurrentMsTime() - daymsTime;
var startTime = this.longMsTimeConvertToDateTime(yesterDatsmsTime);
var pastDate = this.formatterDate2(new Date(startTime));
var nowDate = this.formatterDate2(new Date());
var obj = {
startTime : pastDate,
endTime : nowDate
};
return obj;
},
/**
* 获取今天[开始时间和结束时间值]
*/
getTodayDateTime : function() {
var daymsTime = 24 * 60 * 60 * 1000;
var tomorrowDatsmsTime = this.getCurrentMsTime() + daymsTime;
var currentTime = this.longMsTimeConvertToDateTime(this.getCurrentMsTime());
var termorrowTime = this.longMsTimeConvertToDateTime(tomorrowDatsmsTime);
var nowDate = this.formatterDate2(new Date(currentTime));
var tomorrowDate = this.formatterDate2(new Date(termorrowTime));
var obj = {
startTime : nowDate,
endTime : tomorrowDate
};
return obj;
},
/**
* 获取明天[开始时间和结束时间值]
*/
getTomorrowDateTime : function() {
var daymsTime = 24 * 60 * 60 * 1000;
var tomorrowDatsmsTime = this.getCurrentMsTime() + daymsTime;
var termorrowTime = this.longMsTimeConvertToDateTime(tomorrowDatsmsTime);
var theDayAfterTomorrowDatsmsTime = this.getCurrentMsTime()+ (2 * daymsTime);
var theDayAfterTomorrowTime = this.longMsTimeConvertToDateTime(theDayAfterTomorrowDatsmsTime);
var pastDate = this.formatterDate2(new Date(termorrowTime));
var nowDate = this.formatterDate2(new Date(theDayAfterTomorrowTime));
var obj = {
startTime : pastDate,
endTime : nowDate
};
return obj;
}
};
var TimeObjectUtil;
/**
* @title 时间工具类
* @note 本类一律违规验证返回false
* @author {boonyachengdu@gmail.com}
* @date 2013-07-01
* @formatter "2013-07-01 00:00:00" , "2013-07-01"
*/
TimeObjectUtil = {
/**
* 获取当前时间毫秒数
*/
getCurrentMsTime : function() {
var myDate = new Date();
return myDate.getTime();
},
/**
* 毫秒转时间格式
*/
longMsTimeConvertToDateTime : function(time) {
var myDate = new Date(time);
return this.formatterDateTime(myDate);
},
/**
* 时间格式转毫秒
*/
dateToLongMsTime : function(date) {
var myDate = new Date(date);
return myDate.getTime();
},
/**
* 格式化日期(不含时间)
*/
formatterDate : function(date) {
var datetime = date.getFullYear()
+ "-"// "年"
+ ((date.getMonth() + 1) > 10 ? (date.getMonth() + 1) : "0"
+ (date.getMonth() + 1))
+ "-"// "月"
+ (date.getDate() < 10 ? "0" + date.getDate() : date
.getDate());
return datetime;
},
/**
* 格式化日期(含时间"00:00:00")
*/
formatterDate2 : function(date) {
var datetime = date.getFullYear()
+ "-"// "年"
+ ((date.getMonth() + 1) > 10 ? (date.getMonth() + 1) : "0"
+ (date.getMonth() + 1))
+ "-"// "月"
+ (date.getDate() < 10 ? "0" + date.getDate() : date
.getDate()) + " " + "00:00:00";
return datetime;
},
/**
* 格式化去日期(含时间)
*/
formatterDateTime : function(date) {
var datetime = date.getFullYear()
+ "-"// "年"
+ ((date.getMonth() + 1) > 10 ? (date.getMonth() + 1) : "0"
+ (date.getMonth() + 1))
+ "-"// "月"
+ (date.getDate() < 10 ? "0" + date.getDate() : date
.getDate())
+ " "
+ (date.getHours() < 10 ? "0" + date.getHours() : date
.getHours())
+ ":"
+ (date.getMinutes() < 10 ? "0" + date.getMinutes() : date
.getMinutes())
+ ":"
+ (date.getSeconds() < 10 ? "0" + date.getSeconds() : date
.getSeconds());
return datetime;
},
/**
* 时间比较{结束时间大于开始时间}
*/
compareDateEndTimeGTStartTime : function(startTime, endTime) {
return ((new Date(endTime.replace(/-/g, "/"))) > (new Date(
startTime.replace(/-/g, "/"))));
},
/**
* 验证开始时间合理性{开始时间不能小于当前时间{X}个月}
*/
compareRightStartTime : function(month, startTime) {
var now = formatterDayAndTime(new Date());
var sms = new Date(startTime.replace(/-/g, "/"));
var ems = new Date(now.replace(/-/g, "/"));
var tDayms = month * 30 * 24 * 60 * 60 * 1000;
var dvalue = ems - sms;
if (dvalue > tDayms) {
return false;
}
return true;
},
/**
* 验证开始时间合理性{结束时间不能小于当前时间{X}个月}
*/
compareRightEndTime : function(month, endTime) {
var now = formatterDayAndTime(new Date());
var sms = new Date(now.replace(/-/g, "/"));
var ems = new Date(endTime.replace(/-/g, "/"));
var tDayms = month * 30 * 24 * 60 * 60 * 1000;
var dvalue = sms - ems;
if (dvalue > tDayms) {
return false;
}
return true;
},
/**
* 验证开始时间合理性{结束时间与开始时间的间隔不能大于{X}个月}
*/
compareEndTimeGTStartTime : function(month, startTime, endTime) {
var sms = new Date(startTime.replace(/-/g, "/"));
var ems = new Date(endTime.replace(/-/g, "/"));
var tDayms = month * 30 * 24 * 60 * 60 * 1000;
var dvalue = ems - sms;
if (dvalue > tDayms) {
return false;
}
return true;
},
/**
* 获取最近几天[开始时间和结束时间值,时间往前推算]
*/
getRecentDaysDateTime : function(day) {
var daymsTime = day * 24 * 60 * 60 * 1000;
var yesterDatsmsTime = this.getCurrentMsTime() - daymsTime;
var startTime = this.longMsTimeConvertToDateTime(yesterDatsmsTime);
var pastDate = this.formatterDate2(new Date(startTime));
var nowDate = this.formatterDate2(new Date());
var obj = {
startTime : pastDate,
endTime : nowDate
};
return obj;
},
/**
* 获取今天[开始时间和结束时间值]
*/
getTodayDateTime : function() {
var daymsTime = 24 * 60 * 60 * 1000;
var tomorrowDatsmsTime = this.getCurrentMsTime() + daymsTime;
var currentTime = this.longMsTimeConvertToDateTime(this.getCurrentMsTime());
var termorrowTime = this.longMsTimeConvertToDateTime(tomorrowDatsmsTime);
var nowDate = this.formatterDate2(new Date(currentTime));
var tomorrowDate = this.formatterDate2(new Date(termorrowTime));
var obj = {
startTime : nowDate,
endTime : tomorrowDate
};
return obj;
},
/**
* 获取明天[开始时间和结束时间值]
*/
getTomorrowDateTime : function() {
var daymsTime = 24 * 60 * 60 * 1000;
var tomorrowDatsmsTime = this.getCurrentMsTime() + daymsTime;
var termorrowTime = this.longMsTimeConvertToDateTime(tomorrowDatsmsTime);
var theDayAfterTomorrowDatsmsTime = this.getCurrentMsTime()+ (2 * daymsTime);
var theDayAfterTomorrowTime = this.longMsTimeConvertToDateTime(theDayAfterTomorrowDatsmsTime);
var pastDate = this.formatterDate2(new Date(termorrowTime));
var nowDate = this.formatterDate2(new Date(theDayAfterTomorrowTime));
var obj = {
startTime : pastDate,
endTime : nowDate
};
return obj;
}
};
标签:
Jquery,时间验证,转换工具
无为清净楼资源网 Design By www.qnjia.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
无为清净楼资源网 Design By www.qnjia.com
暂无评论...
更新日志
2024年11月18日
2024年11月18日
- 【雨果唱片】中国管弦乐《鹿回头》WAV
- APM亚流新世代《一起冒险》[FLAC/分轨][106.77MB]
- 崔健《飞狗》律冻文化[WAV+CUE][1.1G]
- 罗志祥《舞状元 (Explicit)》[320K/MP3][66.77MB]
- 尤雅.1997-幽雅精粹2CD【南方】【WAV+CUE】
- 张惠妹.2007-STAR(引进版)【EMI百代】【WAV+CUE】
- 群星.2008-LOVE情歌集VOL.8【正东】【WAV+CUE】
- 罗志祥《舞状元 (Explicit)》[FLAC/分轨][360.76MB]
- Tank《我不伟大,至少我能改变我。》[320K/MP3][160.41MB]
- Tank《我不伟大,至少我能改变我。》[FLAC/分轨][236.89MB]
- CD圣经推荐-夏韶声《谙2》SACD-ISO
- 钟镇涛-《百分百钟镇涛》首批限量版SACD-ISO
- 群星《继续微笑致敬许冠杰》[低速原抓WAV+CUE]
- 潘秀琼.2003-国语难忘金曲珍藏集【皇星全音】【WAV+CUE】
- 林东松.1997-2039玫瑰事件【宝丽金】【WAV+CUE】