DateTime
in package
DateTime
Table of Contents
Constants
- DEFAULT_DATE_FORMAT = 'Y-m-d'
- DEFAULT_TIME_FORMAT = 'H:i'
- ICALENDAR_EVENT = 'Ymd\\THis'
- ICALENDAR_EVENT_UTC = 'Ymd\\THis\\Z'
- ISO8601_FORMAT = DATE_ATOM
- ISO8601ZULU_FORMAT = 'Y-m-d\\TH:i:s\\Z'
- RFC3339_FORMAT = DATE_RFC3339
Properties
- $dateFormat : string|null
- Date format
- $dateTime : DateTime
- DateTime object
- $timeFormat : string|null
- Time formats list
- $timeZone : object
- Time zone
Methods
- addInterval() : DateTime
- Add interval
- convert() : string|false
- Convert date string to other format
- create() : DateTime
- Create DateTime obj
- createFromTimestamp() : object
- Create form timestamp
- dateFormat() : string|null
- Return formated date
- dateTimeFormat() : string|null
- Return formated timestsamp with current date and time format
- getCurrentTimestamp() : int
- Get current timestamp
- getCurrentYear() : string
- Get current year
- getDateFormat() : string
- Get date format
- getDateTime() : DateTime
- Get DateTime
- getDay() : string
- Return current day
- getHour() : string
- Return current hour
- getInterval() : array<string|int, mixed>
- Get interval details
- getLastDay() : int
- Get last day of month
- getLocation() : mixed
- Get location
- getMinutes() : string
- Get current minutes
- getMonth() : string
- Get current month
- getTimeFormat() : string
- Get time format
- getTimestamp() : int
- Get timestamp
- getTimeZone() : DateTimeZone|null
- Get time zone
- getTimeZoneName() : string
- Get time zone
- getTimeZoneOffset() : string
- Get time zone offset
- getTimeZonesList() : array<string|int, mixed>|false
- Get time zone list
- getYear() : string
- Get curent year
- isValidTimeZone() : bool
- Return true if time zone is vlaid
- modify() : DateTime
- Modify date time
- setDateFormat() : void
- Set date format
- setDateTime() : void
- Set date time obj
- setTimeFormat() : void
- Set time formats
- setTimestamp() : DateTime
- Set timestamp
- setTimeZone() : void
- Set time zone
- subInterval() : DateTime
- Sub interval
- timeFormat() : string|null
- Return formated time
- today() : DateTime
- Get current date
- toString() : string
- Convert current date time to string.
- toTimestamp() : int
- Comvert date time to timestamp
Constants
DEFAULT_DATE_FORMAT
public
mixed
DEFAULT_DATE_FORMAT
= 'Y-m-d'
DEFAULT_TIME_FORMAT
public
mixed
DEFAULT_TIME_FORMAT
= 'H:i'
ICALENDAR_EVENT
public
mixed
ICALENDAR_EVENT
= 'Ymd\\THis'
ICALENDAR_EVENT_UTC
public
mixed
ICALENDAR_EVENT_UTC
= 'Ymd\\THis\\Z'
ISO8601_FORMAT
public
mixed
ISO8601_FORMAT
= DATE_ATOM
ISO8601ZULU_FORMAT
public
mixed
ISO8601ZULU_FORMAT
= 'Y-m-d\\TH:i:s\\Z'
RFC3339_FORMAT
public
mixed
RFC3339_FORMAT
= DATE_RFC3339
Properties
$dateFormat
Date format
private
static string|null
$dateFormat
= null
$dateTime
DateTime object
private
static DateTime
$dateTime
$timeFormat
Time formats list
private
static string|null
$timeFormat
= null
$timeZone
Time zone
private
static object
$timeZone
Methods
addInterval()
Add interval
public
static addInterval(string $dateInterval) : DateTime
Parameters
- $dateInterval : string
Return values
DateTimeconvert()
Convert date string to other format
public
static convert(string $date[, string|null $format = null ]) : string|false
Parameters
- $date : string
- $format : string|null = null
Return values
string|falsecreate()
Create DateTime obj
public
static create([string|null $date = null ][, string|null $format = null ]) : DateTime
Parameters
- $date : string|null = null
- $format : string|null = null
Return values
DateTimecreateFromTimestamp()
Create form timestamp
public
static createFromTimestamp(int $timestamp[, string|null $format = null ]) : object
Parameters
- $timestamp : int
- $format : string|null = null
Return values
objectdateFormat()
Return formated date
public
static dateFormat(int|null $timestamp[, string|null $format = null ]) : string|null
Parameters
- $timestamp : int|null
- $format : string|null = null
Return values
string|nulldateTimeFormat()
Return formated timestsamp with current date and time format
public
static dateTimeFormat(int|null $timestamp[, string|null $format = null ]) : string|null
Parameters
- $timestamp : int|null
- $format : string|null = null
Return values
string|nullgetCurrentTimestamp()
Get current timestamp
public
static getCurrentTimestamp() : int
Return values
intgetCurrentYear()
Get current year
public
static getCurrentYear() : string
Return values
stringgetDateFormat()
Get date format
public
static getDateFormat() : string
Return values
stringgetDateTime()
Get DateTime
public
static getDateTime() : DateTime
Return values
DateTimegetDay()
Return current day
public
static getDay() : string
Return values
stringgetHour()
Return current hour
public
static getHour() : string
Return values
stringgetInterval()
Get interval details
public
static getInterval(string $intervalText) : array<string|int, mixed>
Parameters
- $intervalText : string
Return values
array<string|int, mixed>getLastDay()
Get last day of month
public
static getLastDay(int|string $month) : int
Parameters
- $month : int|string
Return values
intgetLocation()
Get location
public
static getLocation() : mixed
getMinutes()
Get current minutes
public
static getMinutes() : string
Return values
stringgetMonth()
Get current month
public
static getMonth() : string
Return values
stringgetTimeFormat()
Get time format
public
static getTimeFormat() : string
Return values
stringgetTimestamp()
Get timestamp
public
static getTimestamp() : int
Return values
intgetTimeZone()
Get time zone
public
static getTimeZone() : DateTimeZone|null
Return values
DateTimeZone|nullgetTimeZoneName()
Get time zone
public
static getTimeZoneName() : string
Return values
stringgetTimeZoneOffset()
Get time zone offset
public
static getTimeZoneOffset([DateTime|null $dateTime = null ]) : string
Parameters
- $dateTime : DateTime|null = null
Return values
stringgetTimeZonesList()
Get time zone list
public
static getTimeZonesList() : array<string|int, mixed>|false
Return values
array<string|int, mixed>|falsegetYear()
Get curent year
public
static getYear() : string
Return values
stringisValidTimeZone()
Return true if time zone is vlaid
public
static isValidTimeZone(string|null $name) : bool
Parameters
- $name : string|null
Return values
boolmodify()
Modify date time
public
static modify(string|null $dateText) : DateTime
Parameters
- $dateText : string|null
Return values
DateTimesetDateFormat()
Set date format
public
static setDateFormat([string|null $format = null ]) : void
Parameters
- $format : string|null = null
setDateTime()
Set date time obj
public
static setDateTime([string|null $date = null ][, string|null $format = null ]) : void
Parameters
- $date : string|null = null
- $format : string|null = null
setTimeFormat()
Set time formats
public
static setTimeFormat([string|null $format = null ]) : void
Parameters
- $format : string|null = null
setTimestamp()
Set timestamp
public
static setTimestamp(int $unixTimestamp) : DateTime
Parameters
- $unixTimestamp : int
Return values
DateTimesetTimeZone()
Set time zone
public
static setTimeZone(string|null $name) : void
Parameters
- $name : string|null
subInterval()
Sub interval
public
static subInterval(string $dateInterval) : DateTime
Parameters
- $dateInterval : string
Return values
DateTimetimeFormat()
Return formated time
public
static timeFormat(int|null $timestamp[, string $format = null ]) : string|null
Parameters
- $timestamp : int|null
- $format : string = null
Return values
string|nulltoday()
Get current date
public
static today([string|null $format = null ]) : DateTime
Parameters
- $format : string|null = null
Return values
DateTimetoString()
Convert current date time to string.
public
static toString([string|null $format = null ]) : string
Parameters
- $format : string|null = null
Return values
stringtoTimestamp()
Comvert date time to timestamp
public
static toTimestamp([string|null $date = null ][, string|null $format = null ]) : int
Parameters
- $date : string|null = null
- $format : string|null = null