Replies: 1 comment
-
You were half-way there. After parsing the string to a Date instance, you need to format it back to a string. You can use the https://date-fns.org/docs/format import { parseISO, format } from "date-fns";
const date = parseISO("2022-08-06T00:00-06:00");
// option 1: localizable token `P`
const str1 = format(date, "PP", new Date());
console.log(str1); // Aug 6, 2022
// option 2: manually define each token
const str2 = format(date, "MMM dd, yyyy", new Date());
console.log(str2); // Aug 06, 2022 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
How can I change this
2022-08-06T00:00-06:00
into thisAug 06, 2022
.Here's my code:
But it's output i s this:
Sat Aug 06 2022 00:00:00 GMT-0600 (Mountain Daylight Time)
I want this
Aug 06, 2022
Can someone help?
Beta Was this translation helpful? Give feedback.
All reactions