The following library allows you to manipulate dates in your question. It is often desireable to have questions that use the current date and then some days or months into the future.
It takes advantage of PHP date formatting. A reference to the available formatting codes can be found here. A few useful formats include 'd-M-Y' for dates like 4-Mar-2020 or 'F j, Y' for dates like March 4, 2020. The date format is optional and if left out will default to 'F j, Y'. The intention is that you will select a preferred date format and then pass that consistently to all functions. Finally, the function dates_dateformat can be used to get useful information from the date. For example, $today=today('d-M-Y') can be used to retreive today's date. $weekday = dates_dateformat($today,"l") will retrieve the day of the week. $month = dates_dateformat($today,"F") will retrive the name of the month.
The question 601187 tests this macro library. If you make changes to the library please modify the test question to incorporate your changes and run to make sure that nothing is broken.
function dates_adddays(date,days,format)
Adds days to the given date. Input and output dates are formatted with the given format.
function dates_addmonths(date,weeks,format)
Adds weeks to the given date. Input and output dates are formatted with the given format.
function dates_addmonths(date,months,format)
Adds months to the given date. Input and output dates are formatted with the given format.
function dates_addyears(date,years,format)
Adds years to the given date. Input and output dates are formatted with the given format.
function dates_bomonth(date,format)
Returns the first day of the month for the given date. Input and output dates are formatted with the given format.
function dates_eomonth(date,format)
Returns the last day of the month for the given date. Input and output dates are formatted with the given format.
function dates_diffdays(date1,date2,format)
Returns the number of days between date1 and date2. If date1 is after date2 then this will return a negative number. Input dates are formatted with the given format. This function will truncate the time from the dates when taking the difference. For example, today at 23:30 is one day from tomorrow at 01:30.
function dates_randdate(date1,date2,format)
Returns a random date between date1 and date2. Input dates are formatted with the given format.
function dates_dateformat(date1,newFormat,origFormat)
Returns a date formatted with a new format. A reference to the available formatting codes can be found here.