Description:
In
this example we explain that how to convert date from Thu Jun 09 2016 00:00:00
GMT+0530(India Standard Time) to YYYY-MM-DD format using JavaScript. Or how can
I convert the time format “THU Jun 09 2016 00:00:00 GMT+0530(India Standard
Time)” to YYYY-MM-DD in JavaScript.
So
to convert the date using the Date constructor then split out the individual
time components like using below function code
function
converttoDate(str) {
var date = new Date(str),
mnth = ("0" + (date.getMonth()+1)).slice(-2),
day = ("0" + date.getDate()).slice(-2);
return [ date.getFullYear(), mnth, day ].join("-");
}
converttoDate
("Thu Jan 08 2016 00:00:00 GMT+0530 (India Standard Time)");
//->
"2016-01-08"
0 comments:
Post a Comment