Leaf PHP

Date
in package

Leaf Date ---------------------- Quick date/time manipulation with Leaf

Tags
author

Michael Darko

since
1.1.0

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
Date

day()

Gets or sets the day

public day([int|null $value = null ]) : Date|int
Parameters
$value : int|null = null
Return values
Date|int

endOf()

Get the end of a time unit

public endOf(string $unit) : Date
Parameters
$unit : string
Return values
Date

format()

Get the formatted date according to the string of tokens passed in.

public format([string $format = 'c' ]) : string
Parameters
$format : string = 'c'
Return values
string

from()

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
string

fromNow()

Returns the string of relative time from now.

public fromNow([mixed $valueOnly = false ]) : string
Parameters
$valueOnly : mixed = false
Return values
string

get()

String getter, returns the corresponding information getting from the date instance.

public get(string $unit) : string
Parameters
$unit : string
Return values
string

hour()

Gets or sets the hour

public hour([int|null $value = null ]) : Date|int
Parameters
$value : int|null = null
Return values
Date|int

isAfter()

This indicates whether the date object is after the other supplied date-time.

public isAfter(mixed $date) : bool
Parameters
$date : mixed
Return values
bool

isBefore()

This indicates whether the date object is before the other supplied date-time.

public isBefore(mixed $date) : bool
Parameters
$date : mixed
Return values
bool

isBetween()

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
bool

isBetweenOrEqual()

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
bool

isDateTime()

This indicates whether the date object is a datetime

public isDateTime(mixed $date) : bool
Parameters
$date : mixed
Return values
bool

isLeapYear()

This indicates whether the date object is a leap year.

public isLeapYear() : bool
Return values
bool

isSame()

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
bool

isSameDay()

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
bool

isSameMonth()

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
bool

isSameYear()

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
bool

millisecond()

Gets or sets the millisecond

public millisecond([int|null $value = null ]) : Date|int
Parameters
$value : int|null = null
Return values
Date|int

minute()

Gets or sets the minute

public minute([int|null $value = null ]) : Date|int
Parameters
$value : int|null = null
Return values
Date|int

month()

Gets or sets the month

public month([int|null $value = null ]) : Date|int
Parameters
$value : int|null = null
Return values
Date|int

now()

Get the current date

public now() : string
Return values
string

second()

Gets or sets the second

public second([int|null $value = null ]) : Date|int
Parameters
$value : int|null = null
Return values
Date|int

set()

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
Date

setTimezone()

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
Date

subtract()

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
Date

tick()

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
Date

toDateString()

Return as PHP DateTime object

public toDateString() : string
Return values
string

toDateTime()

Return as PHP DateTime object

public toDateTime() : DateTime
Return values
DateTime

toDateTimeString()

Return as PHP DateTime object

public toDateTimeString() : string
Return values
string

toIsoString()

Return as PHP DateTime object

public toIsoString() : string
Return values
string

toNow()

Returns the string of relative time from now.

public toNow([mixed $valueOnly = false ]) : string
Parameters
$valueOnly : mixed = false
Return values
string

toTimeString()

Return as PHP DateTime object

public toTimeString() : string
Return values
string

year()

Gets or sets the year

public year([int|null $value = null ]) : Date|int
Parameters
$value : int|null = null
Return values
Date|int

        
On this page

Search results