TypeScript: how to compare two dates
TypeScript: how to compare two dates*
TypeScript: how to compare two dates
To compare the values of two dates to understand if the first is greater, less or equal than the second, we can use the Date object that will do what we want.
With Date object we can compare dates using the
The operators require to use .getTime() method.
The following is a my pesonal funtions that I have written on TypeScript to compare two dates.
A common task to do as a frontend developer is to process Date objects, and frequently that means to compare them. Today, I am going to show you the best way to compare dates and some tips that will help you to get the results you expected. This is very important because for example if you want to develop a method that sorts by a Date property, I am pretty sure you will face this issue and you will spend too many hours trying to figure out the actual reason about the error.