These powerful new features will modernize your JavaScript with shorter and more expressive code. This guide will bring you up to speed with all the latest features added in ECMAScript 13. Note that subDays() returns a new Date object without mutating the one passed to it.ġ1 Amazing New JavaScript Features in ES13 It returns a new Date object with the days subtracted. subDays() takes a Date object and the number of days to subtract as arguments. date-fns subDays() functionĪlternatively, we can use the subDays() function from the date-fns NPM package to subtract 30 days from the current date. April 25, 2022Īpril has only 30 days, so passing 40 to setDate() here increments the month by one and sets the day of the month to 10. If the days you specify would change the month or year of the Date, setDate() automatically updates the Date information to reflect this. The Date setDate() method changes the day of the month of the Date object to the number passed as an argument. The Date getDate() method returns a number between 1 and 31 that represents the day of the month of the particular Date.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |