Today, I am sending a javascript tool function for formatting the date, making a memo to myself, and sending it to the person in need. Haha ~~~ [Javascript]/*** format date * @ param {Object} ms indicates the global standard between the specified date and midnight, January 1, January 1, 1970... syntaxHighlighter. all (); today I am sending a javascript tool function for formatting the date, giving myself a memo record, and sending it to the person in need. Haha ~~~
[Javascript]
/**
* Format the date
* @ Param {Object} The MS specifies the number of milliseconds for the global standard time between the date and midnight, January 1, January 1, 1970
* @ Return year-month-date hh: mm
*/
Util. parseToDate = functions (MS ){
Var date = (new Date (parseInt (MS )));
Return formatDate (date, "yyyy-MM-dd mm: hh ");
};
/**
* Format the date
*
* Yyyy ------- year * MM --------- month * Dd --------- day * Hh --------- hour * Mm --------- minute * For example, Util. formatDate (new Date (), 'yyyy-MM-dd mm: hh '); * Or Util. formateDate (new Date (), 'yyyy/MM/dd mm/hh '); ** @ Param {Date} date the Date object to be formatted
* @ Param {Object} style
* @ Return returns the formatted current time.
*/
Util. formatDate = function (date, style ){
Var y = date. getFullYear ();
Var M = "0" + (date. getMonth () + 1 );
M = M. substring (m. lenght-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 );
}
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.