Skip to content
Advertisement

Reading backend data, ISO format date

I get data from the backend that look like that

start: '2022-10-22T00:00:00Z, end: '2022-10-26T00:00:00Z

regarding the discount of a product. So that basically means that the product is discounted until 25.10.22 until 23.59, right? Thought it would be until 26.10.22 until 23.59 and got a bit confused. Thank you!

Advertisement

Answer

It’s precisely what it is.

from 2022-10-22@12am to 2022-10-26@12am

You should use the provided date as is, but I suggest you convert it first to milliseconds before comparing.

There are plenty of well-maintained packages out there that can do the work for you, be it composer or npm, where you’ll just have to supply the dates.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement