Input, output and format of dates in the code

Thursday 28 October 2004 Mathieu Lutfy

Printing a date on screen

- inc/inc_filters.php: format_date($timestamp = '', $format = 'full')

Returns a human readable date in the language of the user.

The date format of the language is set in the translation files. By default, _T('date_format_full') is used.

Parameters:

  • timestamp: can be either in MySQL format or unix epoch format. If empty, format_date will use the current system time/date.
  • format: Must be predefined in the translation files. By default, ’full’ is used. For now, no other formats have been defined.

Input elements to get a date from the user

- inc/inc_presentation.php: get_date_inputs($name = 'select', $date = '')

This returns the html code necessary to show the pulldown menus (combobox) necessary to allow the user to enter the date without making too many mistakes. The html is wrapped inside its own table and returns only the necessary ’input’ types, no form declaration.

Parameters:

  • name: Name of the input types. For if name is "foo", the day input type will have the name and id attribute of "foo_day". Month and year will respectively be "foo_month" and "foo_year". By default it is set to "select" (e.g. select_day) but you should avoid this because having many date forms in the same screen will be confusing and will break XHTML conformity.
  • date: Default date values for the form. If no date is specified, day and month will be blank but year will be set to the current year.

NOTE: Currently the range of years printed by the function are from 1999 to 2006, but this should be subject to global configuration variables that the admin could change.

To send a message Private area Registering with the site xml ?