In a for loop, I want to get different dates for every item. I had implemented the following and it was working fine:
//This retrieves the right dates:
result.date = offer.get("createdAt");
result.updated = exchange.get("updatedAt");
result.expiration = exchange.get("expirationDate");
I was getting:
2017-09-01T20:33:35.245Z
2017-08-01T19:07:15.510Z
2017-07-28T19:43:11.590Z
As I want to convert to date format and get only month, date, year and time, I implement this:
//This brings the same date every time;
var date = Date(offer.get("createdAt"));
result.date = date.substr(4, 17);
result.shortDate = result.date.substr(4, 11);
var expiration = Date(exchange.get("expirationDate"));
result.expiration = expiration.substr(4, 11);
var updated = Date(exchange.get("updatedAt"));
result.updated = updated.substr(4, 11);
But it keeps bringing the same date for every element:
Sep 02 2017 18:08
Sep 02 2017 18:08 (this should be a different date)
Sep 02 2017 18:08 (this should be a different date)
I don't what I am missing! Thanks a lot.