I have the following date format : 2015-02-18T07:07:25.136Z
from my database, I would like to convert it to 07:07:25 18-02-2015
. I keep on getting the following : 10:07:25 , 18-01-2015
.
I am using the following function to give me the above date :
var order_date = item.dateordered;
var date = new Date(order_date),
yr = date.getFullYear(),
month = +date.getMonth() < 10 ? '0' + date.getMonth() : date.getMonth(),
day = +date.getDate() < 10 ? '0' + date.getDate() : date.getDate(),
hour = +date.getHours() < 10 ? '0' + date.getHours() : date.getHours(),
minutes = +date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes(),
seconds = +date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds(),
cleaned_order_date = hour + ':' + minutes + ':' + seconds + ' , ' + day + '-' + month + '-' + yr;
What is the best way to convert the date from 2015-02-18T07:07:25.136Z
to 07:07:25 , 18-02-2015
?