Date
extends Type
in package
implements
TypeInterface
The Date complex data type.
Tags
Table of Contents
Interfaces
- TypeInterface
- The interface for all complex data types.
Properties
- $helper : string
- The error message returned for invalid values.
- $day : string
- The day part.
- $month : string
- The month part.
- $monthName : string
- The textual version of the month, e.g. July.
- $validationRule : string
- The validation rule (reg-ex) applied to Date values.
- $weekday : string
- The textual version of the day, e.g. Monday.
- $year : string
- The year part.
Methods
- __construct() : mixed
- Constructor. Leave $date param empty to default to now.
- __toString() : string
- Used to convert the object to a printable string.
- getDay() : string
- Get the day part.
- getEuroValue() : string
- Get the date value as a string in the format "DD/MM/YYYY".
- getHelper() : string
- Used to get the validation helper message string.
- getMonth() : string
- Get the month part.
- getMonthName() : string
- Get the month part.
- getRule() : string
- Get the validation rule.
- getStartAndEndDate() : array<string|int, mixed>
- Get the start date and the end date of the week of the year provided. Returns an array containing the "start" date and "end" date.
- getUnixValue() : int
- Return the value in UNIX timestamp format.
- getUSValue() : string
- Get the date value as a string in the format "MM/DD/YYYY".
- getValue() : string
- Get the date value as a string in the format "YYYY-MM-DD".
- getWeekday() : string
- Get the textual weekday part, e.g. Monday.
- getYear() : string
- Get the year part.
- increment() : void
- Increment the cunrrent date by the amount provided
- populateFromString() : void
- Accepts a full date string in YYYY-MM-DD format and populates relevent Date attributes.
- setDateValue() : void
- Set the Date attributes to match the three values provided.
- setHelper() : void
- Set the validation helper text.
- setRule() : string
- Set the validation rule.
- setValue() : void
- Accepts a full date string in ISO YYYY-mm-dd format and populates relevent Date attributes.
Properties
$helper
The error message returned for invalid values.
protected
string
$helper
= 'Not a valid date value! A date should be in the ISO format YYYY-MM-DD.'
Tags
$day
The day part.
private
string
$day
Tags
$month
The month part.
private
string
$month
Tags
$monthName
The textual version of the month, e.g. July.
private
string
$monthName
Tags
$validationRule
The validation rule (reg-ex) applied to Date values.
private
string
$validationRule
Tags
$weekday
The textual version of the day, e.g. Monday.
private
string
$weekday
Tags
$year
The year part.
private
string
$year
Tags
Methods
__construct()
Constructor. Leave $date param empty to default to now.
public
__construct([string $date = '' ]) : mixed
Parameters
- $date : string = ''
-
Date string in the ISO format YYYY-MM-DD.
Tags
__toString()
Used to convert the object to a printable string.
public
__toString() : string
Tags
Return values
stringgetDay()
Get the day part.
public
getDay() : string
Tags
Return values
stringgetEuroValue()
Get the date value as a string in the format "DD/MM/YYYY".
public
getEuroValue() : string
Tags
Return values
stringgetHelper()
Used to get the validation helper message string.
public
getHelper() : string
Tags
Return values
stringgetMonth()
Get the month part.
public
getMonth() : string
Tags
Return values
stringgetMonthName()
Get the month part.
public
getMonthName() : string
Tags
Return values
stringgetRule()
Get the validation rule.
public
getRule() : string
Tags
Return values
stringgetStartAndEndDate()
Get the start date and the end date of the week of the year provided. Returns an array containing the "start" date and "end" date.
public
static getStartAndEndDate(mixed $week, mixed $year) : array<string|int, mixed>
Parameters
- $week : mixed
- $year : mixed
Tags
Return values
array<string|int, mixed>getUnixValue()
Return the value in UNIX timestamp format.
public
getUnixValue() : int
Tags
Return values
intgetUSValue()
Get the date value as a string in the format "MM/DD/YYYY".
public
getUSValue() : string
Tags
Return values
stringgetValue()
Get the date value as a string in the format "YYYY-MM-DD".
public
getValue() : string
Tags
Return values
stringgetWeekday()
Get the textual weekday part, e.g. Monday.
public
getWeekday() : string
Tags
Return values
stringgetYear()
Get the year part.
public
getYear() : string
Tags
Return values
stringincrement()
Increment the cunrrent date by the amount provided
public
increment(string $amount) : void
Parameters
- $amount : string
-
The amount to increment the date by, e.g. "1 day"
Tags
populateFromString()
Accepts a full date string in YYYY-MM-DD format and populates relevent Date attributes.
public
populateFromString(string $date) : void
Parameters
- $date : string
Tags
setDateValue()
Set the Date attributes to match the three values provided.
public
setDateValue(int $year, int $month, int $day) : void
Parameters
- $year : int
- $month : int
- $day : int
Tags
setHelper()
Set the validation helper text.
public
setHelper(string $helper) : void
Parameters
- $helper : string
Tags
setRule()
Set the validation rule.
public
setRule(mixed $rule) : string
Parameters
- $rule : mixed
Tags
Return values
stringsetValue()
Accepts a full date string in ISO YYYY-mm-dd format and populates relevent Date attributes.
public
setValue(mixed $date) : void
Parameters
- $date : mixed