function DateTimePlus::datePad
Same name in other branches
- 9 core/lib/Drupal/Component/Datetime/DateTimePlus.php \Drupal\Component\Datetime\DateTimePlus::datePad()
- 8.9.x core/lib/Drupal/Component/Datetime/DateTimePlus.php \Drupal\Component\Datetime\DateTimePlus::datePad()
- 11.x core/lib/Drupal/Component/Datetime/DateTimePlus.php \Drupal\Component\Datetime\DateTimePlus::datePad()
Pads date parts with zeros.
Helper function for a task that is often required when working with dates.
Parameters
int $value: The value to pad.
int $size: (optional) Size expected, usually 2 or 4. Defaults to 2.
Return value
string The padded value.
1 call to DateTimePlus::datePad()
- DateTimePlus::arrayToISO in core/
lib/ Drupal/ Component/ Datetime/ DateTimePlus.php - Creates an ISO date from an array of values.
File
-
core/
lib/ Drupal/ Component/ Datetime/ DateTimePlus.php, line 664
Class
- DateTimePlus
- Wraps DateTime().
Namespace
Drupal\Component\DatetimeCode
public static function datePad($value, $size = 2) {
return sprintf("%0" . $size . "d", $value);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.