[svn r18108] Added api_get_datetime() to make it easy to use app-wide the PHP time() function instead of the MySQL NOW() function (see new coding conventions)

skala
Yannick Warnier 17 years ago
parent 9a1f51dc72
commit 274daa6eb8
  1. 10
      main/inc/lib/main_api.lib.php

@ -1642,6 +1642,7 @@ function api_not_allowed($print_headers = false) {
==============================================================================
*/
/**
* Gets a UNIX timestamp from a MySQL datetime format string
* @param $last_post_datetime standard output date in a sql query
* @return unix timestamp
* @author Toon Van Hoecke <Toon.VanHoecke@UGent.be>
@ -1655,6 +1656,15 @@ function convert_mysql_date($last_post_datetime) {
$announceDate = mktime($hour, $min, $sec, $month, $day, $year);
return $announceDate;
}
/**
* Gets a MySQL datetime format string from a UNIX timestamp
* @param int UNIX timestamp, as generated by the time() function. Will be generated if parameter not provided
* @return string MySQL datetime format, like '2009-01-30 12:23:34'
*/
function api_get_datetime($time=null) {
if (!isset($time)) { $time = time();}
return date('Y-m-d H:i:s', $time);
}
/**
* Gets item visibility from the item_property table

Loading…
Cancel
Save