Skip to content

react-native formatting is different - debug mode on/off #2841

Answered by fturmel
jonasgroendahl asked this question in Q&A
Discussion options

You must be logged in to vote

I think this has noting to do with date-fns. I could reproduce the behavior within the interactive code example in React Native's "get started" page just using a native Date object. Works on web, breaks on iOS.

Screen.Recording.2021-06-22.at.12.55.20.PM.mov

The problem is that you are using a string in the Date constructor, which can behave differently depending on the runtime.

Per MDN:

Note: Parsing of date strings with the Date constructor (and Date.parse(), which works the same way) is strongly discouraged due to browser differences and inconsistencies.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/Date

Couple solutions:

  • use a numeric…

Replies: 4 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by fturmel
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #2141 on December 12, 2021 16:46.