You are here

function date_pad in Date 5.2

Same name and namespace in other branches
  1. 5 date_api.module \date_pad()
  2. 6.2 date_api.module \date_pad()
  3. 6 date_api.module \date_pad()
  4. 7.3 date_api/date_api.module \date_pad()
  5. 7 date_api/date_api.module \date_pad()
  6. 7.2 date_api/date_api.module \date_pad()

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: total size expected, usually 2 or 4

Return value

string the padded value

9 calls to date_pad()
date_calc_days_to_date in date_php4/date_php4_calc.inc
Converts number of days to a distant unspecified epoch
date_calc_format in date_php4/date_php4_calc.inc
Formats the date in the given format, much like strfmt()
date_convert in ./date_api.module
Date conversion helper function.
date_days_in_month in ./date_api.module
Identify the number of days in a month for a date.
date_fuzzy_datetime in ./date_api.module
Create valid datetime value from incomplete ISO dates or arrays.

... See full list

File

./date_api.module, line 1288
This module will make the date API available to other modules. Designed to provide a light but flexible assortment of functions and constants, with more functionality in additional files that are not loaded unless other modules specifically include them.

Code

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