Welcome to FrostSW!

FrostMVC PHP Framework

Documentation   |   Version

Date_Time

FrostMVC\Date_Time

use FrostMVC\Date_Time;

Date and time utility methods.

Properties

PropertyTypeDescription
Date_Time::$now mixed

Methods

::Convert() —
::ConvertToTimeZone()

Converts a timezone-aware date string from one timezone to another.

::MySQLDate()

Formats a date/time string for MySQL storage. Returns a 'Y-m-d H:i:s' string by default, or 'Y-m-d' when $dateOnly is true. Returns false when the input is not parseable.

::Now()

Returns and stores the current date/time in the given format. The result is cached in Date_Time::$now.

::PrettyDate()

Formats a date/time string as a human-readable 'Mon DD, YYYY' string. When $dateOnly is false, the time ('h:i a') is appended.

::setTimeZone()

Sets the active PHP timezone for both date functions and the INI setting.

::ToTime()

Formats a time string using the given format. Defaults to 'h:i A' (12-hour with AM/PM).

Convert() static

Date_Time::Convert($intVal, $format = 'd')

No description yet.

Parameters

$intVal mixed
$format mixed Default: 'd'

ConvertToTimeZone() static

Date_Time::ConvertToTimeZone($dateString, $currentTimezone = false, $newTimezone = 'GMT', $format = 'Y-m-d H:i:s')

Converts a timezone-aware date string from one timezone to another.

Parameters

$dateString string

The date string to convert.

$currentTimezone DateTimeZone|false

Source timezone. Defaults to the PHP runtime timezone.

Default: false
$newTimezone string

Target timezone identifier, e.g. 'UTC', 'America/New_York'.

Default: 'GMT'
$format string

Output format string for DateTime::format().

Default: 'Y-m-d H:i:s'

Returns

string

MySQLDate() static

Date_Time::MySQLDate($strTime, $dateOnly = false)

Formats a date/time string for MySQL storage. Returns a 'Y-m-d H:i:s' string by default, or 'Y-m-d' when $dateOnly is true. Returns false when the input is not parseable.

Parameters

$strTime string

Any date/time string accepted by strtotime().

$dateOnly bool

When true, returns only the date portion.

Default: false

Returns

string|false

Now() static

Date_Time::Now($format = 'Y-m-d H:i:s')

Returns and stores the current date/time in the given format. The result is cached in Date_Time::$now.

Parameters

$format string

A PHP date() format string. Defaults to 'Y-m-d H:i:s'.

Default: 'Y-m-d H:i:s'

Returns

string

PrettyDate() static

Date_Time::PrettyDate($strTime, $dateOnly = false)

Formats a date/time string as a human-readable 'Mon DD, YYYY' string. When $dateOnly is false, the time ('h:i a') is appended.

Parameters

$strTime string

Any date/time string accepted by strtotime().

$dateOnly bool

When true, omits the time portion.

Default: false

Returns

string

setTimeZone() static

Date_Time::setTimeZone($timezone)

Sets the active PHP timezone for both date functions and the INI setting.

Parameters

$timezone string

A valid timezone identifier, e.g. 'Asia/Manila', 'UTC'.

ToTime() static

Date_Time::ToTime($time, $format = 'h:i A')

Formats a time string using the given format. Defaults to 'h:i A' (12-hour with AM/PM).

Parameters

$time string

Any time string accepted by strtotime().

$format string

A PHP date() format string.

Default: 'h:i A'

Returns

string

Generated from core/classes/Date_Time.php (FrostMVC ).