To convert a character to a date format:
function GetDate (strdate) { var date = eval ('new date ' + Strdate.replace (/\d+ (? =-[^-]+$)/, return1') ' ); return date;}
Date formatting
//date FormattingDate.prototype.format =function (format) {varo = { "m+": This. GetMonth () +1,//Month "d+": This. GetDate (),// Day "H +": This. GetHours (),//Hour "m+": This. getminutes (),//minute "s+": This. getseconds (),//Second "q+": Math.floor (( This. GetMonth () +3) /3),//Quarter "S": This. Getmilliseconds ()//Millisecond } if(/(y+)/. Test (format)) format= Format.replace (regexp.$1, ( This. getFullYear () +""). substr (4-regexp.$1. length)); for(varKincho)if(NewREGEXP ("("+ K +")"). Test (format)) format= Format.replace (regexp.$1, regexp.$1. length = =1? O[k]: ("xx"+ O[k]). substr (""+O[k]) (length)); returnformat;}View Code
Use: newDate().format(‘yyyy-MM-dd HH:mm:ss‘)
JQ date Formatting