I have a date string in format dd/MM/yyyy and I want to create a Date object from this string. new Date(dd/MM/yyyy)
won't work..
I have this code, that obviously does not work:
function createDateObject(value){
try{
return new Date(value.split('/').**swap(0, 1)**.join('/'));
}
catch(){
return null;
}
}
createDateObject('31/01/2014') => Fri Jan 31 2014 00:00:00 GMT-0200 (Local Daylight Time)
Which is the simplest way to do this?
I wouldn't like to create a lot of temp variables if I could do it in one single line...