I'm working on a feature of a project that changes the color of an element based on the date a record was created. I'm using a Rails Backend and React Frontend. I'm trying to make sure the color goes with the appropriate day and not the day before or after.
In Rails, I have a record where the created_at attribute is "2020-07-29 17:38:00.437423" (PST)
In React, that same record shows its created_at attribute as "2020-07-29T17:38:00.437Z"
1.
new Date("2020-07-29 17:38:00.437423")
//=> Wed Jul 29 2020 17:38:00 GMT-0700 (Pacific Daylight Time)
new Date("2020-07-29T17:38:00.437Z")
//=> Wed Jul 29 2020 10:38:00 GMT-0700 (Pacific Daylight Time)
I've noticed that when I remove the 'Z' in the second version, the time matches up as I expect, but why do these strings return date objects that show a 7-hour difference?