var ds = '2013-03-15 08:50:00';
without any time zone information, you cannot say which day. Assuming your string is in UTC, you can use the Date constructor if you replace the space with “T” and add “Z” to the end:
var ds='2013-03-15 08:50:00'; var day=new Date(ds.replace(' ','T')+'Z'); day.toUTCString()
Fri, 15 March 2013 08:50:00 GMT
You can write a date parsing function that will process ISO or sql formats,
which may be required in some older browsers.
Date.fromISO= function(s){ var day, tz, rx=/^(\d{4}\-\d\d\-\d\d([tT ][\d:\.]*)?)([zZ]|([+\-])(\d\d):(\d\d))?$/, p= rx.exec(s) || []; if(p[1]){ day= p[1].split(/\D/); for(var i= 0, L= day.length;i<L;i++){ day[i]= parseInt(day[i], 10) || 0; }; day[1]-= 1; day= new Date(Date.UTC.apply(Date, day)); if(!day.getDate()) return NaN;
then call Date.fromISO ('2013-03-15 08:50:00') ;
source share