If you’re working with React Native you might have seen this:

Image for post
Image for post

Why is that? The React Native datepicker accepts a JS Date object as input which is maybe not the best idea. A JS Date marks a specific point in time. What a datepicker displays is a date without time and timezone.

What happens if you pass a Date object to the picker? React Native uses Calendar.getInstance() so it uses the local timezone of your device. When you construct a JS Date with less then two parameters JavaScript uses UTC. new Date('1978-08-07').toISOString() results in 1978-08-07T00:00:00.000Z with the timestamp 271296000000. …










About

Florian Hirsch

developer at finanzguru.de

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store