Date
in package
Leaf Date ---------------------- Quick date/time manipulation with Leaf
Tags
Table of Contents
Properties
- $date : DateTime
Methods
- __construct() : mixed
- add() : Date
- Add a duration to the current date
- day() : Date|int
- Gets or sets the day
- endOf() : Date
- Get the end of a time unit
- format() : string
- Get the formatted date according to the string of tokens passed in.
- from() : string
- Returns the string of relative time from a date.
- fromNow() : string
- Returns the string of relative time from now.
- get() : string
- String getter, returns the corresponding information getting from the date instance.
- hour() : Date|int
- Gets or sets the hour
- isAfter() : bool
- This indicates whether the date object is after the other supplied date-time.
- isBefore() : bool
- This indicates whether the date object is before the other supplied date-time.
- isBetween() : bool
- This indicates whether the date object is between the other supplied date-time.
- isBetweenOrEqual() : bool
- This indicates whether the date object is between the other supplied date-time.
- isDateTime() : bool
- This indicates whether the date object is a datetime
- isLeapYear() : bool
- This indicates whether the date object is a leap year.
- isSame() : bool
- This indicates whether the date object is the same as the other supplied date-time.
- isSameDay() : bool
- This indicates whether the date object is the same as the other supplied date-time.
- isSameMonth() : bool
- This indicates whether the date object is the same as the other supplied date-time.
- isSameYear() : bool
- This indicates whether the date object is the same as the other supplied date-time.
- millisecond() : Date|int
- Gets or sets the millisecond
- minute() : Date|int
- Gets or sets the minute
- month() : Date|int
- Gets or sets the month
- now() : string
- Get the current date
- second() : Date|int
- Gets or sets the second
- set() : Date
- Generic setter, accepting unit as first argument, and value as second, returns a new instance with the applied changes.
- setTimezone() : mixed
- Set default date timezone
- startOf() : Date
- Get the start of a time unit
- subtract() : Date
- Subtract a duration to the current date
- tick() : Date
- Base method for all date/time operations
- toDateString() : string
- Return as PHP DateTime object
- toDateTime() : DateTime
- Return as PHP DateTime object
- toDateTimeString() : string
- Return as PHP DateTime object
- toIsoString() : string
- Return as PHP DateTime object
- toNow() : string
- Returns the string of relative time from now.
- toTimeString() : string
- Return as PHP DateTime object
- year() : Date|int
- Gets or sets the year
Properties
$date
protected
DateTime
$date
Methods
__construct()
public
__construct() : mixed
add()
Add a duration to the current date
public
add(mixed $duration[, string|null $interval = null ]) : Date
Parameters
- $duration : mixed
- $interval : string|null = null
Return values
Dateday()
Gets or sets the day
public
day([int|null $value = null ]) : Date|int
Parameters
- $value : int|null = null
Return values
Date|intendOf()
Get the end of a time unit
public
endOf(string $unit) : Date
Parameters
- $unit : string
Return values
Dateformat()
Get the formatted date according to the string of tokens passed in.
public
format([string $format = 'c' ]) : string
Parameters
- $format : string = 'c'
Return values
stringfrom()
Returns the string of relative time from a date.
public
from([mixed $date = 'now' ][, mixed $valueOnly = false ]) : string
Parameters
- $date : mixed = 'now'
- $valueOnly : mixed = false
Return values
stringfromNow()
Returns the string of relative time from now.
public
fromNow([mixed $valueOnly = false ]) : string
Parameters
- $valueOnly : mixed = false
Return values
stringget()
String getter, returns the corresponding information getting from the date instance.
public
get(string $unit) : string
Parameters
- $unit : string
Return values
stringhour()
Gets or sets the hour
public
hour([int|null $value = null ]) : Date|int
Parameters
- $value : int|null = null
Return values
Date|intisAfter()
This indicates whether the date object is after the other supplied date-time.
public
isAfter(mixed $date) : bool
Parameters
- $date : mixed
Return values
boolisBefore()
This indicates whether the date object is before the other supplied date-time.
public
isBefore(mixed $date) : bool
Parameters
- $date : mixed
Return values
boolisBetween()
This indicates whether the date object is between the other supplied date-time.
public
isBetween([mixed $date1 = 'now' ][, mixed $date2 = 'now' ]) : bool
Parameters
- $date1 : mixed = 'now'
- $date2 : mixed = 'now'
Return values
boolisBetweenOrEqual()
This indicates whether the date object is between the other supplied date-time.
public
isBetweenOrEqual([mixed $date1 = 'now' ][, mixed $date2 = 'now' ]) : bool
Parameters
- $date1 : mixed = 'now'
- $date2 : mixed = 'now'
Return values
boolisDateTime()
This indicates whether the date object is a datetime
public
isDateTime(mixed $date) : bool
Parameters
- $date : mixed
Return values
boolisLeapYear()
This indicates whether the date object is a leap year.
public
isLeapYear() : bool
Return values
boolisSame()
This indicates whether the date object is the same as the other supplied date-time.
public
isSame([mixed $date = 'now' ]) : bool
Parameters
- $date : mixed = 'now'
Return values
boolisSameDay()
This indicates whether the date object is the same as the other supplied date-time.
public
isSameDay([mixed $date = 'now' ]) : bool
Parameters
- $date : mixed = 'now'
Return values
boolisSameMonth()
This indicates whether the date object is the same as the other supplied date-time.
public
isSameMonth([mixed $date = 'now' ]) : bool
Parameters
- $date : mixed = 'now'
Return values
boolisSameYear()
This indicates whether the date object is the same as the other supplied date-time.
public
isSameYear([mixed $date = 'now' ]) : bool
Parameters
- $date : mixed = 'now'
Return values
boolmillisecond()
Gets or sets the millisecond
public
millisecond([int|null $value = null ]) : Date|int
Parameters
- $value : int|null = null
Return values
Date|intminute()
Gets or sets the minute
public
minute([int|null $value = null ]) : Date|int
Parameters
- $value : int|null = null
Return values
Date|intmonth()
Gets or sets the month
public
month([int|null $value = null ]) : Date|int
Parameters
- $value : int|null = null
Return values
Date|intnow()
Get the current date
public
now() : string
Return values
stringsecond()
Gets or sets the second
public
second([int|null $value = null ]) : Date|int
Parameters
- $value : int|null = null
Return values
Date|intset()
Generic setter, accepting unit as first argument, and value as second, returns a new instance with the applied changes.
public
set(string $unit, int $value) : Date
Parameters
- $unit : string
- $value : int
Return values
DatesetTimezone()
Set default date timezone
public
setTimezone([string $timezone = "Africa/Accra" ]) : mixed
Parameters
- $timezone : string = "Africa/Accra"
startOf()
Get the start of a time unit
public
startOf(string $unit) : Date
Parameters
- $unit : string
Return values
Datesubtract()
Subtract a duration to the current date
public
subtract(mixed $duration[, string|null $interval = null ]) : Date
Parameters
- $duration : mixed
- $interval : string|null = null
Return values
Datetick()
Base method for all date/time operations
public
tick([mixed $userDate = 'now' ][, string|null $userTimeZone = null ]) : Date
Parameters
- $userDate : mixed = 'now'
- $userTimeZone : string|null = null
Return values
DatetoDateString()
Return as PHP DateTime object
public
toDateString() : string
Return values
stringtoDateTime()
Return as PHP DateTime object
public
toDateTime() : DateTime
Return values
DateTimetoDateTimeString()
Return as PHP DateTime object
public
toDateTimeString() : string
Return values
stringtoIsoString()
Return as PHP DateTime object
public
toIsoString() : string
Return values
stringtoNow()
Returns the string of relative time from now.
public
toNow([mixed $valueOnly = false ]) : string
Parameters
- $valueOnly : mixed = false
Return values
stringtoTimeString()
Return as PHP DateTime object
public
toTimeString() : string
Return values
stringyear()
Gets or sets the year
public
year([int|null $value = null ]) : Date|int
Parameters
- $value : int|null = null