You are here

public static function OfficeHoursDateHelper::createFromFormat in Office Hours 8

Creates a date object from an input format.

Wrapper function to centralize all Date/Timefunctions into DateHelper class.

zone

Parameters

string $format: PHP date() type format for parsing the input. This is recommended to use things like negative years, which php's parser fails on, or any other specialized input with a known format. If provided the date will be created using the createFromFormat() method.

mixed $time:

array $settings:

  • validate_format: (optional) Boolean choice to validate the created date using the input format. The format used in createFromFormat() allows slightly different values than format(). Using an input format that works in both functions makes it possible to a validation step to confirm that the date created from a format string exactly matches the input. This option indicates the format can be used for validation. Defaults to TRUE.

Return value

\Drupal\Core\Datetime\DrupalDateTime A new DateTimePlus object.

See also

http://php.net/manual/datetime.createfromformat.php

__construct()

1 call to OfficeHoursDateHelper::createFromFormat()
OfficeHoursDatelist::valueCallback in src/Element/OfficeHoursDatelist.php
Callback for office_hours_select element.

File

src/OfficeHoursDateHelper.php, line 308

Class

OfficeHoursDateHelper
Defines lots of helpful functions for use in massaging dates.

Namespace

Drupal\office_hours

Code

public static function createFromFormat($format, $time, $timezone = NULL, array $settings = []) {
  return DrupalDateTime::createFromFormat($format, $time, $timezone, $settings);
}