It seems like you have a date format issue. It sounds as though you are supplying dates as strings in dd.mm.yyyy
format (or something similar) but the browser is interpreting it as mm.dd.yyyy
. You may even be seeing a warning in the browser console which relates to this.
If you send the date as a string the browser has no way to know whether you meant 10th Sept or 9th Oct, so it just has to guess.
Background: some cultures (e.g. UK and much of Europe) use dd.mm.yyyy
, some use mm.dd.yyyy
(e.g. USA) to present dates (to human beings), some use something else again. There's variation in the order of the elements, the separators used, and the conventions for when to use particular formats in different situations. As you've now learned, it's a bad idea to tie your data to one of these idiosyncratic formats. Computers cannot guess which culture you are intending to represent with your data.
Whilst it's certainly possible to tell the browser how to correctly interpret your ambiguous date, the simple, foolproof solution to this is not to use ambiguous date formats to begin with. Instead, use a non-ambiguous date format such as ISO 8601 - i.e. basically yyyy-mm-dd
(for the date part).