- Symphony 2.6.9
-
› assets
14 -
› boot
14 -
› core
23 -
› cryptography
4 -
› data-sources
6 -
› email-gateways
3 -
› events
3 -
› global
59 -
› interface
9 -
› toolkit
59 - Delegates92
- Deprecated27
Versions
- 2.7.9
- 2.7.8
- 2.7.7
- 2.7.6
- 2.7.5
- 2.7.3
- 2.7.2
- 2.7.10
- 2.7.1
- 2.7.0
- 2.6.9
- 2.6.8
- 2.6.7
- 2.6.6
- 2.6.5
- 2.6.4
- 2.6.3
- 2.6.2
- 2.6.11
- 2.6.10
- 2.6.1
- 2.6.0
- 2.5.3
- 2.5.2
- 2.5.1
- 2.5.0
- 2.4
- 2.3.6
- 2.3.5
- 2.3.4
- 2.3.3
- 2.3.2
- 2.3.1
- 2.3
- 2.2.5
- 2.2.4
- 2.2.3
- 2.2.2
- 2.2.1
- 2.2
Options
public class DateTimeObj
class.datetimeobj.php #14The DateTimeObj provides static functions regarding dates in Symphony.
Symphony will set the default timezone of the system using the value from
the Configuration values. Alternatively a new settings can be set using the
setSettings
function. Symphony parses all input dates against the Configuration
date formats by default for better support with non English dates.
Methods
static string convertDateToMoment(
$format)
Returns the Moment representation of a given PHP format token.
Parameters
static string convertMomentToDate(
$format)
Returns the PHP representation of a given Moment format token.
Parameters
static string convertMomentToTime(
$format)
Returns the PHP time representation of a given Moment format token.
Parameters
static string convertTimeToMoment(
$format)
Returns the Moment time representation of a given PHP format token.
Parameters
static string|boolean format(
$string, $format, $localize, $timezone)
Formats the given date and time $string
based on the given $format
.
Optionally the result will be localized and respect a timezone differing
from the system default. The default output is ISO 8601.
Parameters
Returns
The formatted date, or if the date could not be parsed, false.
static string|boolean get(
$format, $timestamp, $timezone)
Given a $format
, and a $timestamp
,
return the date in the format provided. This function is a basic
wrapper for PHP's DateTime object. If the $timestamp
is omitted,
the current timestamp will be used. Optionally, you pass a
timezone identifier with this function to localise the output
If you like to display a date in the backend, please make use
of DateTimeObj::format()
which allows date and time localization
Parameters
Returns
The formatted date, of if the date could not be parsed, false.
See Also
static array getDateFormatMappings()
Returns an array of PHP date formats Symphony supports mapped to their Moment equivalent.
static array getDateFormats()
Returns an array of the date formats Symphony supports. These formats are a combination of valid PHP format tokens.
See Also
static array getDateFormatsSelectOptions(
$selected)
Returns an array of the date formats Symphony supports by applying
the format to the current datetime. The array returned is for use with
Widget::Select()
Parameters
Returns
An associative array, for use with Widget::Select
See Also
static string getGMT(
$format, $timestamp)
A wrapper for get, this function will force the GMT timezone.
Parameters
Returns
The formatted date in GMT
static array getMomentDateFormats()
Returns an array of the date formats Symphony supports. These formats are a combination of valid Moment format tokens.
See Also
static array getMomentTimeFormats()
Returns an array of the time formats Symphony supports. These formats are a combination of valid Moment format tokens.
See Also
static array|string|null getSetting(
$name)
Accessor function for the settings of the DateTimeObj. Currently
the available settings are time_format
, date_format
,
datetime_format
and datetime_separator
. If $name
is not
provided, the entire $settings
array is returned.
Returns
If $name
is omitted this function returns array. If $name
is not set, this fucntion returns null
If $name
is set, this function returns string
static array getTimeFormats()
Returns an array of the time formats Symphony supports. These formats are a combination of valid PHP format tokens.
See Also
static array getTimeFormatsSelectOptions(
$selected)
Returns an array of the time formats Symphony supports by applying
the format to the current datetime. The array returned is for use with
Widget::Select()
Parameters
Returns
An associative array, for use with Widget::Select
See Also
static array getTimezones(
$zone)
This functions acts as a standard way to get the timezones regardless of PHP version. It accepts a single parameter, zone, which returns the timezones associated with that 'zone'
Parameters
See Also
static array getTimezonesSelectOptions(
$selected)
Loads all available timezones using getTimezones()
and builds an
array where timezones are grouped by their region (Europe/America etc.)
The options array that is returned is designed to be used with
Widget::Select
Parameters
Returns
An associative array, for use with Widget::Select
See Also
static array getZones()
This functions acts as a standard way to get the zones available on the system.
See Also
static DateTime|boolean parse(
$string)
Parses the given string and returns a DateTime object.
Parameters
Returns
The DateTime object, or if the date could not be parsed, false.
static void setDefaultTimezone(
$timezone)
Uses PHP's datedefaulttimezone_set function to set the system
timezone. If the timezone provided is invalid, a E_USER_WARNING
will be
raised.
Parameters
See Also
static void setSettings(
$settings)
This function takes an array of settings for DateTimeObj
to use when parsing
input dates. The following settings are supported, time_format
, date_format
,
datetime_separator
and timezone
. This equates to Symphony's default region
group set in the Configuration
class. If any of these values are not provided
the class will fallback to existing self::$settings
values
Parameters
static boolean validate(
$string)
Validate a given date and time string
Parameters
Returns
Returns true for valid dates, otherwise false