Exploring Dates object
Dates are a complex topic for any programming language or system as you need to take into account many things, such as time zones. If you need to work with dates intensively, consider using a library such as Lunox (https://github.com/moment/luxon/) or date-fns (https://date-fns.org/).
For more simple scenarios, you can use the built-in Date
object and the Intl API (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl) to format dates.
The API offers several ways to generate the Date object by using numbers, strings, or several arguments. Also, you have getters and setters to read and modify specific parts, such as the year or milliseconds. It is also possible to perform operations such as comparing or adding time.
For many years, the only way to format dates in JavaScript was using the toLocaleString()
method. This method is still valid, but it has a lot of limitations, specifically, when you want to compare dates in...