Bitrix API

Date

Table of Contents

Methods

__clone()  : void
Produces the copy of the object.
__construct()  : mixed
__toString()  : string
Converts a date to the string with default culture format setting.
add()  : $this
Performs dates arithmetic.
convertFormatToPhp()  : string
Converts date format from culture to php format.
createFromPhp()  : static
Creates Date object from PHP \DateTime object.
createFromText()  : DateTime|null
Creates Date object from Text (return array of result object) Examples: "end of next week", "tomorrow morning", "friday 25.10"
createFromTimestamp()  : static
Creates Date object from Unix timestamp.
format()  : string
Formats date value to string.
getDiff()  : DateInterval
Returns difference between dates.
getFormat()  : string
Returns a date format from the culture in the php format.
getTimestamp()  : int
Returns Unix timestamp from date.
isCorrect()  : bool
Checks the string for correct date (by trying to create Date object).
setDate()  : $this
Sets the current date of the DateTime object to a different date.
toString()  : string
Converts a date to the string.

Methods

__clone()

Produces the copy of the object.

public __clone() : void

__construct()

public __construct([string|null $date = null ][, string|null $format = null ]) : mixed
Parameters
$date : string|null = null

String representation of date.

$format : string|null = null

PHP date format. If not specified, the format is got from the current culture.

Tags
throws
ObjectException

__toString()

Converts a date to the string with default culture format setting.

public __toString() : string
Return values
string

add()

Performs dates arithmetic.

public add(string $interval) : $this

Each duration period is represented by an integer value followed by a period designator. If the duration contains time elements, that portion of the specification is preceded by the letter T. Period Designators: Y - years, M - months, D - days, W - weeks, H - hours, M - minutes, S - seconds. Examples: two days - 2D, two seconds - T2S, six years and five minutes - 6YT5M. The unit types must be entered from the largest scale unit on the left to the smallest scale unit on the right. Use first "-" char for negative periods. OR Relative period. Examples: "+5 weeks", "12 day", "-7 weekdays", '3 months - 5 days'

Parameters
$interval : string

Time interval to add.

Return values
$this

convertFormatToPhp()

Converts date format from culture to php format.

public static convertFormatToPhp(string $format) : string
Parameters
$format : string

Format string.

Return values
string

createFromPhp()

Creates Date object from PHP \DateTime object.

public static createFromPhp(DateTime $datetime) : static
Parameters
$datetime : DateTime

Source object.

Return values
static

createFromText()

Creates Date object from Text (return array of result object) Examples: "end of next week", "tomorrow morning", "friday 25.10"

public static createFromText(string $text) : DateTime|null
Parameters
$text : string
Return values
DateTime|null

createFromTimestamp()

Creates Date object from Unix timestamp.

public static createFromTimestamp(int $timestamp) : static
Parameters
$timestamp : int

Source timestamp.

Return values
static

format()

Formats date value to string.

public format(string $format) : string
Parameters
$format : string

PHP date format.

Return values
string

getDiff()

Returns difference between dates.

public getDiff(Date $time) : DateInterval
Parameters
$time : Date
Return values
DateInterval

getFormat()

Returns a date format from the culture in the php format.

public static getFormat([Culture|null $culture = null ]) : string
Parameters
$culture : Culture|null = null

Optional culture.

Return values
string

getTimestamp()

Returns Unix timestamp from date.

public getTimestamp() : int
Return values
int

isCorrect()

Checks the string for correct date (by trying to create Date object).

public static isCorrect(string $time[, string $format = null ]) : bool
Parameters
$time : string

String representation of date.

$format : string = null

PHP date format. If not specified, the format is got from the current culture.

Return values
bool

setDate()

Sets the current date of the DateTime object to a different date.

public setDate(int $year, int $month, int $day) : $this
Parameters
$year : int
$month : int
$day : int
Return values
$this

toString()

Converts a date to the string.

public toString([Culture|null $culture = null ]) : string
Parameters
$culture : Culture|null = null

Culture contains date format.

Return values
string

        
On this page

Search results