Copy Code code as follows:
(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 = ("+" + mydate.getmilliseconds ()). Slice (-3);
if (Ismi = = True) {
Return year + "-" + month + "-" + Day + "" + H + ":" + M + ":" + S;
}
else {
Return year + "-" + month + "-" + Day + "" + H + ":" + M + ":" + S + "" + mi;
}
}
}) (JQuery);
How to use:
Copy Code code as follows:
$. FormatDateTime (item. Controlendtime, False)
Item. Controlendtime: Back date in background
False: Boolean, whether to return milliseconds