Is there any simple way to convert the following:
2011-08-31T20:01:32.000Z
In to UK date format: 31-08-2011
and time to: 20:01
Advertisement
Answer
var date = new Date("2011-08-31T20:01:32.000Z").toLocaleDateString(); // date = 2011/08/31 date = date.split("/"); // date = ["31", "08, "2011"] date = date[2] + "-" + (date[0].length == 1 ? "0" + date[0] : date[0]) + "-" + (date[1].length == 1 ? "0" + date[1] : date[1]); // data = 2011-31-08 $("#your-txtbox").val(date);