public static function DateTimePlus::datePad

public static DateTimePlus::datePad($value, $size = 2)

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.

File

core/lib/Drupal/Component/Datetime/DateTimePlus.php, line 614

Class

DateTimePlus
Wraps DateTime().

Namespace

Drupal\Component\Datetime

Code

public static function datePad($value, $size = 2) {
  return sprintf("%0" . $size . "d", $value);
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Component!Datetime!DateTimePlus.php/function/DateTimePlus::datePad/8.1.x