function _opigno_ilt_datetime_to_iso in Opigno Instructor-led Trainings 3.x
Same name and namespace in other branches
- 8 opigno_ilt.module \_opigno_ilt_datetime_to_iso()
Converts database datetime string to the ISO-8601 format without a timezone.
Parameters
string $datetime_string: Datetime string.
Return value
string ISO-8601 without a timezone.
1 call to _opigno_ilt_datetime_to_iso()
- opigno_ilt_opigno_ilt_presave in ./
opigno_ilt.module - Implements hook_ENTITY_TYPE_presave().
File
- ./
opigno_ilt.module, line 27 - Contains opigno_ilt.module.
Code
function _opigno_ilt_datetime_to_iso($datetime_string) {
if (!isset($datetime_string)) {
return NULL;
}
$datetime = DrupalDateTime::createFromFormat(DrupalDateTime::FORMAT, $datetime_string);
return $datetime
->setTimezone(new \DateTimeZone('UTC'))
->format('Y-m-d\\TH:i:s');
}