public static DateTimePlus::arrayToISO($array, $force_valid_date = FALSE)
Creates an ISO date from an array of values.
Parameters
array $array: An array of date values keyed by date part.
bool $force_valid_date: (optional) Whether to force a full date by filling in missing values. Defaults to FALSE.
Return value
string The date as an ISO string.
File
- core/lib/Drupal/Component/Datetime/DateTimePlus.php, line 490
Class
- DateTimePlus
- Wraps DateTime().
Namespace
Drupal\Component\Datetime
Code
public static function arrayToISO($array, $force_valid_date = FALSE) { $array = static::prepareArray($array, $force_valid_date); $input_time = ''; if ($array['year'] !== '') { $input_time = static::datePad(intval($array['year']), 4); if ($force_valid_date || $array['month'] !== '') { $input_time .= '-' . static::datePad(intval($array['month'])); if ($force_valid_date || $array['day'] !== '') { $input_time .= '-' . static::datePad(intval($array['day'])); } } } if ($array['hour'] !== '') { $input_time .= $input_time ? 'T' : ''; $input_time .= static::datePad(intval($array['hour'])); if ($force_valid_date || $array['minute'] !== '') { $input_time .= ':' . static::datePad(intval($array['minute'])); if ($force_valid_date || $array['second'] !== '') { $input_time .= ':' . static::datePad(intval($array['second'])); } } } return $input_time; }
Please login to continue.