This article mainly introduces the JavaScript date format example, the need for friends can refer to the following
Code as follows:/** * format date * @param {Object} MS represents the number of milliseconds between a specified date and the global standard Time between midnight January 1, 1970 * @return year-month-date hh:mm */ util.parsetodate = function (ms) { & nbsp var date = (new Date (parseint (MS)); return formatdate (date, "Yyyy-mm-dd mm:hh"); }; /** * format date * <code> * yyyy-------year * MM---------Month * DD---------Day * hh--------- * mm---------minutes * such as: Util.formatdate (New D Ate (), ' yyyy-mm-dd mm:hh '); * or Util.formatedate (new Date (), ' yyyy/mm/dd mm/hh '); * </code> * @param {date}date Date object that needs to be formatted * @param {object} style style * @return Returns the formatted current time */ util.formatdate = function (date, style) { var y = dat E.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); }