I need to change date format to be dd-mm-YYYY HH:mm:ss. At the moment I am getting YYY-mm-dd HH:mm:ss. Anyone can help me with this?
for (var course in data) {
if (data[course]['days'] == value) {
id[i] = data[course]['id'];
name[i] = data[course]['name'] + " " + data[course]['startDate']['date'];
i++;
}
}
date = date.split('-'); //split and break into array
date = date[2] + '-' + date[1] + '-' + date[0]; //change the order you need
date_parts = date.split(' '); //split and break into array get HH:mm:ss date = date_parts[0].split('-'); date = date[2] + '-' + date[1] + '-' + date[0] + ' ' + date_parts[1]; //change the order you need
Try this:
function formatDate (input) {
var datePart = input.match(/\d+/g),
year = datePart[0].substring(2), // get only two digits
month = datePart[1], day = datePart[2];
return day+'/'+month+'/'+year;
}
alert(formatDate ('2010/01/18')); // "18/01/10"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.