You are here

function date_gmgetdate in Date 5

Same name and namespace in other branches
  1. 5.2 date_php4/date_php4.inc \date_gmgetdate()
  2. 6.2 date_php4/date_php4.inc \date_gmgetdate()
  3. 6 date_php4/date_php4.inc \date_gmgetdate()

We need a gmgetdate function, which does not exist because the getdate function creates an array where date parts and timestamp don't match getdate date parts are timezone-adjusted to the server zone and timestamp is not we need an array where date parts match the timestamp. Check for empty timestamps to make sure empty values don't display as 1/1/1970.

3 calls to date_gmgetdate()
date_convert_timezone in ./date.inc
Timezone conversion function
date_format_date in ./date.inc
Format date
date_unix2array in ./date.inc

File

./date.inc, line 57
Date/time API functions

Code

function date_gmgetdate($timestamp) {
  if ($timestamp === FALSE) {
    return '';
  }
  date_load_library();
  switch (DATE_LIBRARY) {
    case 'ADODB':

      // Must use the private function to force it to GMT.
      $array = _adodb_getdate($timestamp, FALSE, TRUE);
      $array[0] = $timestamp;
      return $array;
    default:

      // The date_adj_zone function corrects for timezone adjustment getdate will add.
      $array = getdate(date_adj_zone($timestamp));
      $array[0] = $timestamp;
      return $array;
  }
}