You are here

function date_pad in Date 7.3

Same name and namespace in other branches
  1. 5.2 date_api.module \date_pad()
  2. 5 date_api.module \date_pad()
  3. 6.2 date_api.module \date_pad()
  4. 6 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: (optional) Total size expected, usually 2 or 4. Defaults to 2.

Return value

string The padded value.

7 calls to date_pad()
DateObject::toISO in date_api/date_api.module
Creates an ISO date from an array of values.
date_days_in_month in date_api/date_api.module
Identifies the number of days in a month for a date.
date_ical_parse_date in date_api/date_api_ical.inc
Parses a ical date element.
date_pager_url in date_views/date_views.module
A version of date_real_url that formats links correctly for the Date pager.
date_views_argument_handler_simple::get_default_argument in date_views/includes/date_views_argument_handler_simple.inc
Set the empty argument value to the current date.

... See full list

File

date_api/date_api.module, line 2267
This module will make the date API available to other modules.

Code

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