Feature Rich
Rapid Application Development
Helping you or your customers
Manage their Business

<-- Back to Guides

Relative Date Formats

Sometimes you might need to create a date or time relative to the current date/time, or even another date.
For this you need to use the Relative Date Format
With this you can user terms such as "Monday Last week" or "Last day of March".
While this is very powerful and flexible, it can be very particular on what you enter so you need to test your request to make sure it is giving you what you need.
e.g.
"Last Tuesday" will give you the last Tuesday that happened, not necessarily the Tuesday from last week.
"-2 Weeks 2 days" will give you "- 2 weeks + 2 Days", not "-2 Weeks -2 Days"


Valid phrases

Day Names 'sunday' | 'monday' | 'tuesday' | 'wednesday' | 'thursday' | 'friday' | 'saturday' | 'sun' | 'mon' | 'tue' | 'wed' | 'thu' | 'fri' | 'sat'
Day Text 'weekday' | 'weekdays'
Numbers + or -, 0 to 9
Ordinal 'first' | 'second' | 'third' | 'fourth' | 'fifth' | 'sixth' | 'seventh' | 'eighth' | 'ninth' | 'tenth' | 'eleventh' | 'twelfth' | 'next' | 'last' | 'previous' | 'this'
Relative Text 'next' | 'last' | 'previous' | 'this'
Units 'sec' | 'second' | 'min' | 'minute' | 'hour' | 'day' | 'fortnight' | 'month' | 'year' | 'weeks' All with or without a following 's'
Other 'yesterday' | 'midnight' | 'today' | 'now' | 'noon' | 'tomorrow' | 'first day of' | 'last day of'

For a technical description of valid formats see https://www.php.net/manual/en/datetime.formats.relative.php.