\Charcoal\Cms\Support\HelpersDateHelper

Class DateHelper

Summary

Methods
Properties
Constants
__construct()
formatDate()
formatTime()
No public properties found
No constants found
No protected methods found
$from
$to
$dateFormats
$timeFormats
$dateFormat
$timeFormat
N/A
getDateCase()
getTimeCase()
formatDateFromCase()
formatTimeFromCase()
parseAsDate()
crossPlatformFormat()
No private properties found
N/A

Properties

$from

$from : \DateTime

Type

\DateTime

$to

$to : \DateTime

Type

\DateTime

$dateFormats

$dateFormats : array

Type

array — The date formats options from config.

$timeFormats

$timeFormats : array

Type

array — The time formats options from config.

$dateFormat

$dateFormat : string

Type

string — The format from dateFormats to use for the date

$timeFormat

$timeFormat : string

Type

string — The format from dateFormats to use for the time

Methods

__construct()

__construct(array  $data) 

DateHelper constructor.

Parameters

array $data

DateHelper data.

Throws

\Exception

When constructor's data missing.

formatDate()

formatDate(mixed  $date, string  $format = 'default') : string

Parameters

mixed $date

The date [startDate, endDate] DateTimeInterface string.

string $format

The format to use.

Returns

string

formatTime()

formatTime(mixed  $date, string  $format = 'default') : string

Parameters

mixed $date

The date [startDate, endDate] DateTimeInterface string.

string $format

The format to use.

Returns

string

getDateCase()

getDateCase() : string

Get the usage case by comparing two dates.

Returns

string

getTimeCase()

getTimeCase() : string

Get the usage case by comparing two hours.

Returns

string

formatDateFromCase()

formatDateFromCase(string  $case) : string

Parameters

string $case

The use case.

Returns

string

formatTimeFromCase()

formatTimeFromCase(string  $case) : string

Parameters

string $case

The use case.

Returns

string

parseAsDate()

parseAsDate(mixed  $date) : \DateTime

Parameters

mixed $date

The date to convert.

Returns

\DateTime

crossPlatformFormat()

crossPlatformFormat(mixed  $format) : mixed

Parameters

mixed $format

DateTime to be formatted.

Returns

mixed