JavaScript date Format Sample Sharing _ Basics

Source: Internet
Author: User

Copy Code code as follows:

/**
* Date of format
* @param {Object} MS represents the number of milliseconds between the specified date and the global standard Time between midnight and January 1, 1970
* @return Year-month-date hh:mm
*/
Util.parsetodate = function (ms) {
var date = (new Date (parseint (MS));
return FormatDate (date, "Yyyy-mm-dd mm:hh");
};
/**
* Date of format
* <code>
* YYYY-------Years
* MM---------Month
* DD---------Day
* When HH---------
* mm---------Points
* such as: Util.formatdate (New Date (), ' yyyy-mm-dd mm:hh ');
* or Util.formatedate (new Date (), ' yyyy/mm/dd mm/hh ');
* </code> * @param {date}date Date objects that need to be formatted
* @param {Object} style style
* @return Returns the current time formatted
*/
Util.formatdate = function (date, style) {
var y = date.getfullyear ();
var M = "0" + (date.getmonth () + 1);
M = m.substring (m.length-2);
var d = "0" + date.getdate ();
D = d.substring (d.length-2);
var h = "0" + date.gethours ();
h = h.substring (h.length-2);
var m = "0" + date.getminutes ();
m = m.substring (m.length-2);
return style.replace (' yyyy ', y). Replace (' mm ', m). Replace (' DD ', D). Replace (' hh ', h). replace (' mm ', m);
}

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.