/*
* 関数名: DateUtil
* 作成者: yithcn
* 関数の説明: Date 関数
* 使用方法:
* 作成日: 2010.10.14
*/
var DateUtil = {}; .base = 60 * 60 * 24 * 1000;
DateUtil.Add = function(num, sDate) {
num = sDate || new Date(); >varbase = this.base * num;
var todayMs = sDate.getTime();
sDate.setTime(todayMs); ) 1);
m d = d var y = sDate.getFull Year();
return m "/" d "/" y;
DateUtil.Diff = function(sDate, eDate, mode) {
if (typeof sDate == "string")
sDate = new Date(sDate);
if (typeof eDate == "string")
eDate = new Date(eDate); sDate || new Date();
eDate = eDate || new Date();
sDate.getyear();
return (0) );
}
var result = Math.abs(eDate - sDate);
switch (mode) {
case "y":
result /= this.base
break;
case "m":
result /= this.base * 365 / 12;
case "w":
result /= this.base * 7 ;
ブレーク;
デフォルト:
結果 /= this.base;
戻り値 (Math.floor(result)); >DateUtil.Time = function(hasSec) {
var date = new Date();
return date.getHours() ":" date.getMinutes() (hasSec ? ":" date.getSeconds() : "");
};
DateUtil.TimeSplit = function(hasSec) {
var date = new Date();
return { 時間: date.getHours(), 分: date.getMinutes ()、秒 : (hasSec ? ":" date.getSeconds() : "") };