A Web page date format plug-in based on jquery _jquery

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.