DIV CSS 佈局教程網

 DIV+CSS佈局教程網 >> 網頁腳本 >> JavaScript入門知識 >> jQuery入門知識 >> JQuery特效代碼 >> 基於jquery的web頁面日期格式化插件
基於jquery的web頁面日期格式化插件
編輯:JQuery特效代碼     
. 代碼如下:
(function ($) {
var FormatDateTime = function FormatDateTime() { };
$.FormatDateTime = function (obj, IsMi) {
var correcttime1 = eval('( new ' + obj.replace(new RegExp("\/", "gm"), "") + ')');
var myDate = correcttime1;
var year = myDate.getFullYear();
var month = ("0" + (myDate.getMonth() + 1)).slice(-2);
var day = ("0" + myDate.getDate()).slice(-2);
var h = ("0" + myDate.getHours()).slice(-2);
var m = ("0" + myDate.getMinutes()).slice(-2);
var s = ("0" + myDate.getSeconds()).slice(-2);
var mi = ("00" + myDate.getMilliseconds()).slice(-3);
if (IsMi == true) {
return year + "-" + month + "-" + day + " " + h + ":" + m + ":" + s;
}
else {
return year + "-" + month + "-" + day + " " + h + ":" + m + ":" + s + " " + mi;
}

}
})(jQuery);


使用方法:
. 代碼如下:
$.FormatDateTime(item.ControlEndTime, false)

//item.ControlEndTime:後台返回的日期
//false:布爾型,是否返回毫秒
XML學習教程| jQuery入門知識| AJAX入門| Dreamweaver教程| Fireworks入門知識| SEO技巧| SEO優化集錦|
Copyright © DIV+CSS佈局教程網 All Rights Reserved