Date
in package
General date functions.
Table of Contents
Properties
- $quarters : array<string|int, mixed>
Methods
- compare() : int
- dateToJulian() : int
- daysAsText() : string
- diff() : int
- differenceUnitAsText() : string
- Turns a time difference into a text format.
- getCurrentMonthEndDate() : string
- getCurrentMonthStartDate() : string
- Returns the current month starting date.
- getDateRangeForMonth() : DateRange
- Returns the date range for a year/month number.
- getDateRangeForQuarter() : DateRange
- Returns the date range for the specified fiscal quarter.
- getDateRangeForWeek() : DateRange
- Returns the date range for a specific year/week number.
- getDay() : false|string
- Get the day name for a date.
- getDaysInMonth() : int
- getWeekday() : int
- Returns an int representing the day of the week.
- getWorkingDays() : int
- Get the number of working days in a date range.
- isLeapYear() : bool
- Returns true if the date ia leap year.
- isWeekend() : bool
- Is the date on a weekend?
- julianToDate() : string
- only() : false|string
- If present, strips the time element from a date.
- subtractDays() : bool|string
- today() : false|string
- Return today's date
- tomorrow() : false|string
- Return tomorrow's date
- yesterday() : false|string
- Return yesterday's date
Properties
$quarters
private
static array<string|int, mixed>
$quarters
= [1 => ["01-01", "03-31"], 2 => ["04-01", "06-30"], 3 => ["07-01", "09-30"], 4 => ["10-01", "12-31"]]
Methods
compare()
public
static compare(string $first, string $second) : int
Parameters
- $first : string
- $second : string
Return values
intdateToJulian()
public
static dateToJulian(mixed $date) : int
Parameters
- $date : mixed
Return values
intdaysAsText()
public
static daysAsText(mixed $days) : string
Parameters
- $days : mixed
Return values
stringdiff()
public
static diff(mixed $endDate, mixed $beginDate) : int
Parameters
- $endDate : mixed
- $beginDate : mixed
Return values
intdifferenceUnitAsText()
Turns a time difference into a text format.
public
static differenceUnitAsText(mixed $time[, mixed $until = null ]) : string
Parameters
- $time : mixed
- $until : mixed = null
Return values
stringgetCurrentMonthEndDate()
public
static getCurrentMonthEndDate() : string
Return values
stringgetCurrentMonthStartDate()
Returns the current month starting date.
public
static getCurrentMonthStartDate() : string
Return values
string —A string in yyyy-mm-dd mysql format.
getDateRangeForMonth()
Returns the date range for a year/month number.
public
static getDateRangeForMonth([int $month = 0 ][, string $year = '' ]) : DateRange
Parameters
- $month : int = 0
- $year : string = ''
Return values
DateRangegetDateRangeForQuarter()
Returns the date range for the specified fiscal quarter.
public
static getDateRangeForQuarter([int $quarter = 0 ][, string $year = '' ]) : DateRange
Parameters
- $quarter : int = 0
- $year : string = ''
Return values
DateRangegetDateRangeForWeek()
Returns the date range for a specific year/week number.
public
static getDateRangeForWeek([int $week = 0 ][, string $year = '' ]) : DateRange
Parameters
- $week : int = 0
- $year : string = ''
Return values
DateRangegetDay()
Get the day name for a date.
public
static getDay(mixed $date) : false|string
Parameters
- $date : mixed
Return values
false|stringgetDaysInMonth()
public
static getDaysInMonth(mixed $month[, null $year = null ]) : int
Parameters
- $month : mixed
- $year : null = null
Tags
Return values
intgetWeekday()
Returns an int representing the day of the week.
public
static getWeekday(string $date) : int
0 = Sunday .. 6 = Saturday
Parameters
- $date : string
Return values
intgetWorkingDays()
Get the number of working days in a date range.
public
static getWorkingDays(DateRange $range) : int
Parameters
- $range : DateRange
Return values
intisLeapYear()
Returns true if the date ia leap year.
public
static isLeapYear(mixed $year) : bool
Parameters
- $year : mixed
Return values
boolisWeekend()
Is the date on a weekend?
public
static isWeekend(mixed $date) : bool
Parameters
- $date : mixed
Return values
booljulianToDate()
public
static julianToDate(mixed $julianDate) : string
Parameters
- $julianDate : mixed
Return values
stringonly()
If present, strips the time element from a date.
public
static only(mixed $dateTime) : false|string
Parameters
- $dateTime : mixed
Return values
false|stringsubtractDays()
public
static subtractDays(mixed $days[, string $date = '' ]) : bool|string
Parameters
- $days : mixed
- $date : string = ''
Return values
bool|string —- new date
today()
Return today's date
public
static today() : false|string
Return values
false|stringtomorrow()
Return tomorrow's date
public
static tomorrow() : false|string
Return values
false|stringyesterday()
Return yesterday's date
public
static yesterday() : false|string