1 (function ($) {
2 var FormatDateTime = function FormatDateTime() { };
3 $.FormatDateTime = function (obj, IsMi) {
4 var correcttime1 = eval('( new ' + obj.replace(new RegExp("\/", "gm"), "") + ')');
5 var myDate = correcttime1;
6 var year = myDate.getFullYear();
7 var month = ("0" + (myDate.getMonth() + 1)).slice(-2);
8 var day = ("0" + myDate.getDate()).slice(-2);
9 var h = ("0" + myDate.getHours()).slice(-2);
10 var m = ("0" + myDate.getMinutes()).slice(-2);
11 var s = ("0" + myDate.getSeconds()).slice(-2);
12 var mi = ("00" + myDate.getMilliseconds()).slice(-3);
13 if (IsMi == true) {
14 return year + "-" + month + "-" + day + " " + h + ":" + m + ":" + s;
15 }
16 else {
17 return year + "-" + month + "-" + day + " " + h + ":" + m + ":" + s + " " + mi;
18 }
19
20 }
21 })(jQuery);

 

使用方法:

$.FormatDateTime(item.ControlEndTime, false)

//item.ControlEndTime:后台返回的日期
//
false:布尔型,是否返回毫秒



posted on 2011-11-15 17:16  网络终结者  阅读(677)  评论(0编辑  收藏  举报