Get the time in JavaScript and then upload to the background for action

Source: Internet
Author: User
Tags local time

/**
* When using Ajax to pass time to the background (sometimes not in the background new date () can be resolved), this method to convert the local time format (Beijing) to the Date delivery background
*/
var datenow = new Date ();
Date = Format (Datenow, ' yyyy-mm-dd HH:mm:ss ');

/**
* These two functions are to get the international time of the foreground, which is easy to operate in the background
*/
var format = function (time, format) { //front desk acquisition times, converted to international time, can be used as tools
var t = new Date (time);
var tf = function (i) {return (I < 10?) ' 0 ': "") + i};
Return Format.replace (/yyyy| mm|dd| hh|mm|ss/g, function (a) {
Switch (a) {
Case ' yyyy ':
Return TF (T.getfullyear ());
Break
Case ' MM ':
Return TF (T.getmonth () + 1);
Break
Case ' mm ':
Return TF (T.getminutes ());
Break
Case ' DD ':
Return TF (T.getdate ());
Break
Case ' HH ':
Return TF (T.gethours ());
Break
Case ' SS ':
Return TF (T.getseconds ());
Break
}
})
}

Get the time in JavaScript and then upload to the background for action

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.