0

How to use toISOString to get DD MMM YYY HH:MM. I tried this way..

<%= locals.user.stats.dateLastLogin.toISOString().replace("T"," ").replace("Z","") %>

output: 2016-12-13 08:08:22.929

requird output: 12 DEC 2016 08:08pm

Cœur
  • 37,241
  • 25
  • 195
  • 267
swati kiran
  • 675
  • 1
  • 4
  • 22
  • iso format is `YYYY-MM-DDTHH:MM:SS.nnnZ` - replacing the T and Z isn't exactly trying to get the date format you want, is it – Jaromanda X Dec 14 '16 at 05:48
  • Related: [Where can I find documentation on formatting a date in JavaScript?](https://stackoverflow.com/questions/1056728/where-can-i-find-documentation-on-formatting-a-date-in-javascript) – Jonathan Lonowski Dec 14 '16 at 05:54
  • Native date handling in js is quite terrible, if you have the option, look into using [moment.js](http://momentjs.com/), then you could just do `moment(locals.user.stats.dateLastLogin).format('DD MMM YYYY hh:MM:A')` – dtkaias Dec 14 '16 at 05:57

0 Answers0