Calculates the difference (in months) between two dates. Use Date.prototype.getFullYear() and Date.prototype.getMonth() to calculate the difference (in months) between two Date objects. Source https://www.30secondsofcode.org/js/s/get-months-diff-between-dates
Time & Date
Gets the Unix timestamp from a Date object. Use Date.prototype.getTime() to get the timestamp in milliseconds and divide by 1000 to get the timestamp in seconds. Use Math.floor() to appropriately round the resulting timestamp to an integer. Omit the argument, date, to use the current date. Source https://www.30secondsofcode.org/js/s/get-timestamp
Results in a string representation of yesterday’s date. Use the Date constructor to get the current date. Decrement it by one using Date.prototype.getDate() and set the value to the result using Date.prototype.setDate(). Use Date.prototype.toISOString() to return a string in yyyy-mm-dd format. Source https://www.30secondsofcode.org/js/s/yesterday
Subtract the two Date objects and divide by the number of milliseconds in an hour to get the difference (in hours) between them. Source https://www.30secondsofcode.org/js/s/get-hours-diff-between-dates
Use Date.prototype.toISOString() and strict equality checking (===) to check if the first date is the same as the second one.
Use new Date(), setting the date to February 29th of the given year. Use Date.prototype.getMonth() to check if the month is equal to 1.
Use Date.prototype.getDay() to check weekend by using a modulo operator (%).
Here’s a trick for getting back a formatted month name (like January or Jan).
Here’s a way to get the date for the next occurrence of a specific day of the week.