Contao Utils Bundle

DateUtil
in package

Table of Contents

Properties

$container  : ContainerInterface
$framework  : ContaoFramework

Methods

__construct()  : mixed
convertSecondsToHumanReadableFormat()  : mixed
getDaysBetween()  : float|int
getFormattedDateTime()  : string|null
getFormattedDateTimeByEvent()  : string|null
getGMTMidnightTstamp()  : int
transfer a given timestamp to a gmt timestamp at midnight.
getMonthTranslationMap()  : mixed
getShortMonthTranslationMap()  : mixed
getTimePeriodInSeconds()  : float|int|null
Returns the time in seconds of an given time period.
getTimeStamp()  : int
Get the timestamp based on input date, no matter input is timestamp or string date.
isDayInDateFormat()  : bool
Checks if a form of day is available in the date format.
isMonthInDateFormat()  : bool
Checks if a form of month is available in the date format.
isYearInDateFormat()  : bool
Checks if a form of year is available in the date format.
transformPhpDateFormatToISO8601()  : string
Format a php date formate pattern to an ISO8601 compliant format.
transformPhpDateFormatToRFC3339()  : string
Format a php date formate pattern to an RFC3339 compliant format.
translateMonths()  : mixed|string
Translates available months inside a given string from English to the current language.
translateMonthsToEnglish()  : mixed|string
Translates available months inside a given string into their English representations taking into account the current language.

Properties

$container

protected ContainerInterface $container

$framework

protected ContaoFramework $framework

Methods

__construct()

public __construct(ContainerInterface $container) : mixed
Parameters
$container : ContainerInterface

convertSecondsToHumanReadableFormat()

public convertSecondsToHumanReadableFormat(mixed $seconds) : mixed
Parameters
$seconds : mixed

getDaysBetween()

public getDaysBetween(int $smallerTimestamp[, int $largerTimestamp = null ][, bool $returnFullDays = false ]) : float|int
Parameters
$smallerTimestamp : int
$largerTimestamp : int = null
$returnFullDays : bool = false

If true, only full days are returned (0.67 -> 0)

Return values
float|int

getFormattedDateTime()

public getFormattedDateTime(mixed $startDate[, mixed $endDate = 0 ][, mixed $addTime = false ][, mixed $startTime = 0 ][, mixed $endTime = 0 ][, array<string|int, mixed> $options = [] ]) : string|null
Parameters
$startDate : mixed
$endDate : mixed = 0
$addTime : mixed = false
$startTime : mixed = 0
$endTime : mixed = 0
$options : array<string|int, mixed> = []
Return values
string|null

getFormattedDateTimeByEvent()

public getFormattedDateTimeByEvent(Model $event) : string|null
Parameters
$event : Model
Return values
string|null

getGMTMidnightTstamp()

transfer a given timestamp to a gmt timestamp at midnight.

public getGMTMidnightTstamp(int $tstamp) : int
Parameters
$tstamp : int
Return values
int

getMonthTranslationMap()

public getMonthTranslationMap() : mixed

getShortMonthTranslationMap()

public getShortMonthTranslationMap() : mixed

getTimePeriodInSeconds()

Returns the time in seconds of an given time period.

public getTimePeriodInSeconds(string|array<string|int, mixed> $timePeriod) : float|int|null
Parameters
$timePeriod : string|array<string|int, mixed>

Array or serialized string containing an value and an unit key

Return values
float|int|null

getTimeStamp()

Get the timestamp based on input date, no matter input is timestamp or string date.

public getTimeStamp([string|int|DateTime|null $date = null ][, bool $replaceInsertTags = true ][, string|null $timezone = null ]) : int
Parameters
$date : string|int|DateTime|null = null

The input date/timestamp/insertTag

$replaceInsertTags : bool = true

Disable/enable {{date::}} insertTag support

$timezone : string|null = null

A valid timezone from DateTimeZone::ALL, if provided the timezone offset will be added to the timestamp

Tags
throws
Exception

Throws error in case of an error when creating new DateTime instances

Return values
int

The integer timestamp presentation of the input date with added timezone offset

isDayInDateFormat()

Checks if a form of day is available in the date format.

public isDayInDateFormat(string $dateFormat) : bool
Parameters
$dateFormat : string
Return values
bool

isMonthInDateFormat()

Checks if a form of month is available in the date format.

public isMonthInDateFormat(string $dateFormat) : bool
Parameters
$dateFormat : string
Return values
bool

isYearInDateFormat()

Checks if a form of year is available in the date format.

public isYearInDateFormat(string $dateFormat) : bool
Parameters
$dateFormat : string
Return values
bool

transformPhpDateFormatToISO8601()

Format a php date formate pattern to an ISO8601 compliant format.

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

The date format (e.g. "d.m.y H:i")

Return values
string

The ISO8601 compliant format (see: https://de.wikipedia.org/wiki/ISO_8601)

transformPhpDateFormatToRFC3339()

Format a php date formate pattern to an RFC3339 compliant format.

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

The php date format (see: http://php.net/manual/de/function.date.php#refsect1-function.date-parameters)

Return values
string

The RFC3339 compliant format (see: http://userguide.icu-project.org/formatparse/datetime#TOC-Date-Time-Format-Syntax or http://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table)

translateMonths()

Translates available months inside a given string from English to the current language.

public translateMonths(string $date) : mixed|string
Parameters
$date : string
Return values
mixed|string

translateMonthsToEnglish()

Translates available months inside a given string into their English representations taking into account the current language.

public translateMonthsToEnglish(string $date) : mixed|string
Parameters
$date : string
Return values
mixed|string

        
On this page

Search results