Convert Date
to string
to get year, month & date
#2549
-
I am making a blog & I have an ---
.
.
date: '2020-09-12T14:54:37.229Z'
.
.
--- I have set the type to of this export type Meta = {
.
date: Date
.
} I want to parse this import { getYear, getMonth, getDate, parseISO } from 'date-fns'
console.log(getYear(parseISO(tutorial.date.toDateString()))) But I get an error:
If I pass
I can't get to figure out how to just convert a |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Lmfao, 6+ hours of Googling & found the answer by googling const d = new Date(tutorial.date)
console.log(getYear(d)) |
Beta Was this translation helpful? Give feedback.
Lmfao, 6+ hours of Googling & found the answer by googling
convert utc string to date javascript
after 1 min of posting: