1 date.inc date_pad($value, $size = 2)

Helper function to left pad date parts with zeros.

Provided because this is needed so often with dates.

Parameters

int $value: The value to pad.

int $size: (optional) Total size expected, usually 2 or 4. Defaults to 2.

Return value

string: The padded value.

File

core/includes/date.inc, line 1087
Date API functions.

Code

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