Format date? #21
-
Is there a way to pass a formatting argument? i.e. |
Beta Was this translation helpful? Give feedback.
Answered by
AbhyudayaSharma
Jan 3, 2022
Replies: 1 comment
-
Hi @paulywill. The date is returned as a strict ISO8601 string and can be passed to a const date = new Date(gitInfo.commit.date);
const options = {
year: 'numeric', month: 'numeric', day: 'numeric',
hour: 'numeric', minute: 'numeric', second: 'numeric',
hour12: false,
timeZone: 'America/Los_Angeles'
};
console.log(new Intl.DateTimeFormat('en-US', options).format(date)) |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
paulywill
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi @paulywill. The date is returned as a strict ISO8601 string and can be passed to a
Date
constructor. You can then useIntl.DateTimeFormat
with that date to format it to your liking.