Closed sacrosanctic closed 1 year ago
Just remove createdDate
from dates
if you want the value as a string instead of a date.
Or do you want a Date
object and the problem is Invalid Date
?
I want a date object
Have you tried to remove .getTime()
?
The code above is demonstrating a scenario where the incoming date is a Timestamp.
Since new Date(new Date().getTime())
will work.
Is parsing Timestamp as date outside the scope of this package?
Isn't Date
converted to a string when send to the server via FormData
? What should work is new Date().toISOString()
.
This was the solution is found for myself as well, I just thought maybe the case where a user uses .getTime()
should be handled for better DX.
Yes, we can add this use case. Do you want to create a PR or should I take care of it? That's the file: https://github.com/fabian-hiller/decode-formdata/blob/main/src/utils/getFieldDate/getFieldDate.ts
I can do it.
Formdata content is always stored as a string. So if I am sending a Timestamp to the server it will be converted to a string and fail.
Repro
Demo
Expected
Actual
Suggestion
Addtional Info
btw, your package is awesome.