React-native: Date.toLocaleDateString() ignores country settings on Android

Created on 23 Jun 2016  路  17Comments  路  Source: facebook/react-native

  • [x] Provide a minimal code snippet / rnplay example that reproduces the bug.
    let testDate = Date.UTC(2016, 6, 23, 10, 0, 0, 0);
    let output = new Date(testDate).toLocaleDateString();
    return         <Text style={styles.text}>{output}</Text>;

https://rnplay.org/apps/bGMmOA
- [x] Provide screenshots where appropriate
1. go to phone settings and change the language to Deutsch (Deutschland)
sample_app___react_native_playground
2. launch the app
on_device

Expected:

23.06.2016

Actual:

07/23/16

  • [x] What's the version of React Native you're using?

0.28

  • [x] Does this occur on iOS, Android or both?

only Android, on iOS this works fine.

  • [x] Are you using Mac, Linux or Windows?

Mac

Locked

Most helpful comment

This definitely shouldn't be closed.
new Date().toLocaleDateString() still isn't working correctly, and is really a basic feature.

All 17 comments

Is there any progress on this? I also have this issue on 0.30.

+1

I've got same issue

The issue is also reproducable with 0.40.0

same issue

Still have this issue with 0.43.3

this issue is really annoying and i can't understand how this issue can be open since nearly a year.
sure there are tons of date-format-npm-packages out there, but that's so unnecessary.

btw this is related: http://stackoverflow.com/questions/42218022/react-native-reacts-differently-when-not-debugging-remotely

Still reproducible with 0.46.3.

+1

This is because JSC on Android doesn't include the locale settings. It would increase the size of the APK by ~2MB so it's not clear whether we want to include this.

Hi there! This issue is being closed because it has been inactive for a while. Maybe the issue has been fixed in a recent release, or perhaps it is not affecting a lot of people. Either way, we're automatically closing issues after a period of inactivity. Please do not take it personally!

If you think this issue should definitely remain open, please let us know. The following information is helpful when it comes to determining if the issue should be re-opened:

  • Does the issue still reproduce on the latest release candidate? Post a comment with the version you tested.
  • If so, is there any information missing from the bug report? Post a comment with all the information required by the issue template.
  • Is there a pull request that addresses this issue? Post a comment with the PR number so we can follow up.

If you would like to work on a patch to fix the issue, contributions are very welcome! Read through the contribution guide, and feel free to hop into #react-native if you need help planning your contribution.

imho the issue should stay open, as far as i know it is still a problem in the latest release, and the issue is inactive for a while because people accept it as problem and use workarounds.

Is there a PR open that attempts to address the issue?

now seems use new Date().toLocaleDateString() crash directly in android huawei phone with 1.0.0, while it is ok in ios,
use new Date().toString() ok

Same here with @jayzhou215. Tried with physical Samsung Galaxy Note 4, Android Studio and Genymotion emulated Google Pixel 7.1.0 API 25.

new Date().toDateString() is also ok. Should be sth. about locales.

This definitely shouldn't be closed.
new Date().toLocaleDateString() still isn't working correctly, and is really a basic feature.

I also have the same problem. Using react-native version 0.55.4
If I used Remote JS Debugging in device, date showing correctly, but when I stop it date format incorrect

Was this page helpful?
0 / 5 - 0 ratings