I have a date/time string like 2012-01-13 04:37:20
but I want to convert it to dd-mm-yyyy hh:mm
, how can i do this?
I am using the followin
You can do a simple string manipulation and create js date object. See function below, which accepts date in format //yyyy-mm-dd hh:mm:ss
DEMO here
function toJSDate (dateTime) {
var dateTime = dateTime.split(" ");//dateTime[0] = date, dateTime[1] = time
var date = dateTime[0].split("-");
var time = dateTime[1].split(":");
//(year, month, day, hours, minutes, seconds, milliseconds)
return new Date(date[0], date[1], date[2], time[0], time[1], time[2], 0);
}