I have a datetimes coming back from my database in ISO format. They look like this: 2015-11-03T10:06:50.000Z
. I am using moment.js to parse it out so that it's more readable and the result looks like this: 11-03-2015 10:06:50 AM
. I simply want to add another space between the date and time so it's easier to read. Any thoughts?
I've tried adding another space between the date and time in moment and it appears that it strips out all spaces except one. I've also tried hyphens and pipes but those don't really look the way I want.
rows.forEach(row => {
// TODO find a way to put more blank space between date and time
let formattedDateTime = moment.utc(row.DateTime).format(`MM-DD-YYYY hh:mm:ss A`)
row.DateTime = formattedDateTime
// console.log('formatted datetime', formattedDateTime)
})
Expected: adding spaces between the date and time in moment.format would reflect that way on the client.
Actual: only allowed one space between date and time. All other spaces are removed.
have the same requirement, the solution is to use \xa0
moment(date).format('YYYY-MMM-DD\xa0\xa0\xa0HH:mm');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With