public static function WebformDateHelper::createFromFormat in Webform 6.x
Same name and namespace in other branches
- 8.5 src/Utility/WebformDateHelper.php \Drupal\webform\Utility\WebformDateHelper::createFromFormat()
Creates a date object from an input format with a translated date string.
Parameters
string $format: PHP date() type format for parsing the input.
mixed $time: A date string.
mixed $timezone: PHP DateTimeZone object, string or NULL allowed.
array $settings: An array of settings.
Return value
\Drupal\Core\Datetime\DrupalDateTime|bool A new DateTimePlus object or FALSE if invalid date string.
See also
\Drupal\Core\Datetime\DrupalDateTime::__construct
2 calls to WebformDateHelper::createFromFormat()
- DateBase::validateDate in src/
Plugin/ WebformElement/ DateBase.php - Webform element validation handler for date elements.
- ScheduleEmailWebformHandler::validateConfigurationForm in modules/
webform_scheduled_email/ src/ Plugin/ WebformHandler/ ScheduleEmailWebformHandler.php - Form validation handler.
File
- src/
Utility/ WebformDateHelper.php, line 108
Class
- WebformDateHelper
- Helper class webform date helper methods.
Namespace
Drupal\webform\UtilityCode
public static function createFromFormat($format, $time, $timezone = NULL, array $settings = []) {
$english_time = WebformDateHelper::convertDateStringToEnglish($format, $time);
try {
return DrupalDateTime::createFromFormat($format, $english_time, $timezone, $settings);
} catch (\Exception $exception) {
return FALSE;
}
}