var TimeObjectUtil;
/**
* @title 時間工具類
* @note 本類一律違規驗證返回false
* @author {boonyachengdu@gmail
* @date
* @formatter "
*/
TimeObjectUtil = {
/**
* 獲取當前時間毫秒數
*/
getCurrentMsTime : function() {
var myDate = new Date();
return myDate
}
/**
* 毫秒轉時間格式
*/
longMsTimeConvertToDateTime : function(time) {
var myDate = new Date(time);
return this
}
/**
* 時間格式轉毫秒
*/
dateToLongMsTime : function(date) {
var myDate = new Date(date);
return myDate
}
/**
* 格式化日期(不含時間)
*/
formatterDate : function(date) {
var datetime = date
+ "
+ ((date
+ (date
+ "
+ (date
return datetime;
}
/**
* 格式化日期(含時間"
*/
formatterDate
var datetime = date
+ "
+ ((date
+ (date
+ "
+ (date
return datetime;
}
/**
* 格式化去日期(含時間)
*/
formatterDateTime : function(date) {
var datetime = date
+ "
+ ((date
+ (date
+ "
+ (date
+ " "
+ (date
+ ":"
+ (date
+ ":"
+ (date
return datetime;
}
/**
* 時間比較{結束時間大於開始時間}
*/
compareDateEndTimeGTStartTime : function(startTime
return ((new Date(endTime
startTime
}
/**
* 驗證開始時間合理性{開始時間不能小於當前時間{X}個月}
*/
compareRightStartTime : function(month
var now = formatterDayAndTime(new Date());
var sms = new Date(startTime
var ems = new Date(now
var tDayms = month *
var dvalue = ems
if (dvalue > tDayms) {
return false;
}
return true;
}
/**
* 驗證開始時間合理性{結束時間不能小於當前時間{X}個月}
*/
compareRightEndTime : function(month
var now = formatterDayAndTime(new Date());
var sms = new Date(now
var ems = new Date(endTime
var tDayms = month *
var dvalue = sms
if (dvalue > tDayms) {
return false;
}
return true;
}
/**
* 驗證開始時間合理性{結束時間與開始時間的間隔不能大於{X}個月}
*/
compareEndTimeGTStartTime : function(month
var sms = new Date(startTime
var ems = new Date(endTime
var tDayms = month *
var dvalue = ems
if (dvalue > tDayms) {
return false;
}
return true;
}
/**
* 獲取最近幾天[開始時間和結束時間值
*/
getRecentDaysDateTime : function(day) {
var daymsTime = day *
var yesterDatsmsTime = this
var startTime = this
var pastDate = this
var nowDate = this
var obj = {
startTime : pastDate
endTime : nowDate
};
return obj;
}
/**
* 獲取今天[開始時間和結束時間值]
*/
getTodayDateTime : function() {
var daymsTime =
var tomorrowDatsmsTime = this
var currentTime = this
var termorrowTime = this
var nowDate = this
var tomorrowDate = this
var obj = {
startTime : nowDate
endTime : tomorrowDate
};
return obj;
}
/**
* 獲取明天[開始時間和結束時間值]
*/
getTomorrowDateTime : function() {
var daymsTime =
var tomorrowDatsmsTime = this
var termorrowTime = this
var theDayAfterTomorrowDatsmsTime = this
var theDayAfterTomorrowTime = this
var pastDate = this
var nowDate = this
var obj = {
startTime : pastDate
endTime : nowDate
};
return obj;
}
};
From:http://tw.wingwit.com/Article/program/Java/JSP/201311/20083.html