Formatting Dates

MySQL

There are four variables that can be used to format a date within a MySQL query:

  • $cfg_short_date = '%d/%m/%y';
  • $cfg_long_date = '%d/%m/%Y';
  • $cfg_long_date_time = '%d/%m/%Y %H:%i';
  • $cfg_short_date_time = '%d/%m/%y %H:%i';

The above date formats can be altered in /config/config.inc.php. To use within code they can be picked up through the configObject:

$result = $mysqli->prepare("SELECT DATE_FORMAT(start_date, '" . $configObject->get('cfg_long_date_time') . "') FROM properties WHERE paper_type = '2';

Note

Any changes to the date format config items above should be reflected in the following config item used by the jquery table sorter:

  • $cfg_tablesorter_date_time = 'uk';