The process of development often encounter time-formatted things, for those timestamps, 2015-05-05,2015/05/05, etc. can be well converted into the format you want
function FormatDate (strdate, Strformat)
{
if (!strdate) return;
if (!strformat) format = "YYYY-MM-DD";
Switch (typeof strdate)
{
Case "string":
Strdate = new Date (Strdate.replace (/-/g, "/"));
Break
Case "Number":
Strdate = new Date (strdate);
Break
}
if (!strdate instanceof Date) return;
var dict = {
"yyyy": strdate.getfullyear (),
"M": Strdate.getmonth () + 1,
"D": strdate.getdate (),
"H": strdate.gethours (),
"M": strdate.getminutes (),
"S": Strdate.getseconds (),
"MM": ("" + (Strdate.getmonth () + 101). substr (1),
"DD": ("" + (Strdate.getdate () +)). substr (1),
"HH": ("" + (Strdate.gethours () +)). substr (1),
"MM": ("" + (Strdate.getminutes () +)). substr (1),
"SS": ("" + (Strdate.getseconds () +). substr (1)
};
Return Strformat.replace (/(yyyy| mm?| dd?| hh?| ss?| MM?) /g, function ()
{
return dict[arguments[0]];
});
}
FormatDate (strdate, "Yyyy-mm-dd HH:mm:ss")
JS time format