I
I
Igor2021-09-13 10:35:10
JavaScript
Igor, 2021-09-13 10:35:10

How to reformat time type '08-Sep-2021 20:41:21' to 'Sep 8, 2021, 20:41:21' in Luxonjs?

How to reformat time type '08-Sep-2021 20:41:21' to 'Sep 8, 2021, 20:41:21' in Luxonjs?
To further calculate the interval between dates.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
low molecular macro, 2021-09-13
@molekulyarniy

Get the date via luxon.DATETIME_FULL_WITH_SECONDS
Or why not convert with built-in JS tools?

const options = {
  year: 'numeric',
  month: 'short',
  day: 'numeric',
  timezone: 'UTC',
  hour: 'numeric',
  minute: 'numeric',
  second: 'numeric'
};

let date = new Date(2021, 8, 8, 20, 41, 21);

date.toLocaleString("en-US", options);

what will give you back
"Sep 8, 2021, 8:41:21 PM"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question