prisma datetime type not assignable to string
Answered
Black-whiskered Vireo posted this in #help-forum
Black-whiskered VireoOP
I have a prisma object which has a coloumn of type DateTime.
in the prop here you see I have given it type Date because of that..
how can I fix this error now
in the prop here you see I have given it type Date because of that..
how can I fix this error now
Answered by chisto
try making it string
{String(time)}
or time.toLocaleDateString()
or toLocaleTimeString()
{String(time)}
or time.toLocaleDateString()
or toLocaleTimeString()
9 Replies
Black-whiskered VireoOP
try making it string
{String(time)}
or time.toLocaleDateString()
or toLocaleTimeString()
{String(time)}
or time.toLocaleDateString()
or toLocaleTimeString()
Answer
Black-whiskered VireoOP
nice thanks done
British Shorthair
Or use momentjs or datejs to actually format the date for displaying. These libraries can handle both as input: string or date
Black-whiskered VireoOP
does this convert the data to string on the client side or server side?
all of this code runs on the server side right? so how to format the date to the users preference instead of the servers
British Shorthair
The code runs wherever your component runs.
If you want to make sure to suit it to your users preferences, you either take the accept language header (on the server) or the browser locale (on the client). Alternatively you allow storing a preference in the user profile.