class DateFunction

This class provides some date functions for the expression parser.

Methods

static DateTime
nthDayOfMonth(int $nth, int $day, int $month, int $year)

Returns the date corresponding of the nth day of a month

static int
lastDay(int $month, int $year)

Returns the last day of the month

static DateTime
firstDayOfMonth(DateTime $dateObj)

Returns a new date corresponding to the first day of the month of the given date.

static DateTime
lastDayOfMonth(DateTime $dateObj)

Returns a new date corresponding to the last day of the month of the given date.

static DateTime
addMonths(int $months, DateTime $dateObject)

Returns a new date from the input date by adding the given number of months

Details

at line 52
static DateTime nthDayOfMonth(int $nth, int $day, int $month, int $year)

Returns the date corresponding of the nth day of a month

Ex: nthDayOfMonth(1, 0, 1, 2017) for the question: what is the first sunday of January 2017

Parameters

int $nth The ordinal number
int $day The day of the week (0 to 6)
int $month The numeric representation of a month (1 to 12)
int $year The year

Return Value

DateTime

at line 71
static int lastDay(int $month, int $year)

Returns the last day of the month

Ex: lastDay(2, 2017) returns 28.

Parameters

int $month The numeric representation of the month (1 to 12)
int $year The year

Return Value

int

at line 86
static DateTime firstDayOfMonth(DateTime $dateObj)

Returns a new date corresponding to the first day of the month of the given date.

Parameters

DateTime $dateObj The reference date

Return Value

DateTime The new date

at line 101
static DateTime lastDayOfMonth(DateTime $dateObj)

Returns a new date corresponding to the last day of the month of the given date.

Parameters

DateTime $dateObj The reference date

Return Value

DateTime The new date

at line 117
static DateTime addMonths(int $months, DateTime $dateObject)

Returns a new date from the input date by adding the given number of months

Parameters

int $months The number of months to add
DateTime $dateObject The date to which a number of months has to be added.

Return Value

DateTime The new date