You are here

function date_pad in Date 7

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.3 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

6 calls to date_pad()
DateObject::toISO in date_api/date_api.module
Create an ISO date from an array of values.
date_days_in_month in date_api/date_api.module
Identify the number of days in a month for a date.
date_ical_parse_date in date_api/date_api_ical.inc
Parse a ical date element.
date_real_url in date_views/date_views.module
Figure out the URL of the date view we're currently looking at, adapted to various date types or specific date arguments.
date_views_filter_handler::date_filter in date_views/includes/date_views_filter_handler.inc

... See full list

File

date_api/date_api.module, line 1545
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);
}