1

Hell,

I am trying to work with dates in React Native and I am struggling to understand why it adds another 2 hours when I call date.getHours().

This is what I receive from backend: 2018-06-03T11:00:00.

This is a final locale date with hours that I should present to the user, so I expect when I call new Date('2018-06-03T11:00:00').getHours() it should return 11. And it works well in a browser without a problem, but when I use it in my React Native project on both platforms (iOS and Android) it returns for me 13 instead of 11.

What am I missing? How to explicitly tell Date that it should not convert it again to date with different timezone?

KamilG
  • 123
  • 1
  • 1
  • 9
  • This will probably solve your problem https://stackoverflow.com/questions/32469269/javascript-date-give-wrong-date-off-by-one-hour#comment52838280_32476132 – Syed Mehtab Hassan Mar 23 '19 at 10:16
  • Thanks, seems to fixed the issue for me. Yet I still don't get it why it works this way... :) – KamilG Mar 31 '19 at 10:31

0 Answers0