Posted in Javascript onNovember 15, 2011
(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:布尔型,是否返回毫秒
基于jquery的web页面日期格式化插件
声明:登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述。
Reply on: @reply_date@
@reply_contents@