0

We developed ReactJS app and used react-datetime for selecting date and Year.

When selecting YEAR in client machine(Windows XP-Firefox 52.09), value(year) decreased by 1. Same thing happen if we use new Date(2018-01-01) converted to "2017-01-01"

Note

My Client using Firefox 52.09 on Windows XP (We know windows xp service ended but client have few + features in XP)

Sample Code

var date = new Date();
React.render(
    <Datetime value = {new Date('2011-01-01')} dateFormat="YYYY"/>,
    document.body
);

Please find Example at https://codepen.io/anon/pen/gdGaNp

Attached screen shot also enter image description here

Satish
  • 391
  • 4
  • 22
  • recreate it on stackblitz, codepen doesn't work on older xp ;) – xadm Sep 06 '18 at 14:25
  • hello @xadm, please find link here https://stackblitz.com/edit/react-azaqag?file=Hello.js – Satish Sep 07 '18 at 08:35
  • `2011` in FF ESR 45.9.0 – xadm Sep 07 '18 at 08:37
  • 2010 in ESR FF 52.9.0 Please find image here https://ibb.co/d1aLPe – Satish Sep 07 '18 at 09:52
  • don't take year alone - check full value in dev-react component props - it can be difference in hours - TZ-related - for `console.log(new Date('2011-01-01'))` I have `Date 2011-01-01T00:00:00.000Z` - difference in minus would be 2010-12-31... – xadm Sep 07 '18 at 10:40
  • Thanks @xadm . Got the issue. Our client using specifying US timezone systems. So i changed code with adding of UTC to selected date – Satish Sep 07 '18 at 11:07
  • XP & FF not guilty ;) – xadm Sep 07 '18 at 11:11

1 Answers1

0

Found the solution

When adding UTC to selected date, it's working

<Datetime value={new Moment.utc(new Date('2011-01-01'))}/>

With UTC and non-UTC Sample https://stackblitz.com/edit/react-e8fa6w?file=Hello.js

Satish
  • 391
  • 4
  • 22