Date objects are converted to strings
See original GitHub issueIn the following scenario the Date()
object is converted to a string
after page refresh:
state: () => {
items: []
}
actions: {
addItem(data) {
const newItem = data
newItem.createdDt = new Date()
this.items.push(newItem)
}
}
When I add the item and retrieve it immediately, it is a Date
object. However, after refreshing the page, when the store is restored from local storage items[0].createdDt
is a string
.
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
How to convert Date to String in Java - GeeksforGeeks
Get an instance of LocalDate from date. Convert the given date into a string using the toString() method of LocalDate class. Print the...
Read more >Java Convert Date to String - javatpoint
Java Date to String Example · Date date = Calendar.getInstance().getTime(); · DateFormat dateFormat = new SimpleDateFormat("yyyy-mm-dd hh:mm:ss"); · String strDate ...
Read more >How to convert a JavaScript date object to a string?
The toISOString() method is used to convert the date object into the ISO string format. It is a built-in method of the Date...
Read more >Date.parse() - JavaScript - MDN Web Docs
The parse() method takes a date string (such as "2011-10-10T14:48:00" ) and returns the number of milliseconds since January 1, 1970, 00:00:00 UTC....
Read more >JavaScript Date toString() Method - W3Schools
Every JavaScript object has a toString() method. The toString() method is used internally by JavaScript when an object needs to be displayed as...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’ll add a line in the “limitations” part of the readme, specifying that serialization loses non primitive types such as Date. Workaround can also be the use of the freshly implemented hooks! 😃
Seems like a wont-fix with a workaround to me, if you’re fine with it.
aa52a70 should close this. Thanks for the contribution!