You are here

function date_date in Date 6.2

Same name and namespace in other branches
  1. 5.2 date_php4/date_php4.inc \date_date()
  2. 5 date.inc \date_date()
  3. 6 date_php4/date_php4.inc \date_date()

Return formatted date based on timestamp $timestamp.

Parameters

$format: the format to be used for the returned timestamp

$timestamp: a unix timestamp

$timezone name: Use 'UTC' to avoid timezone conversion.

1 call to date_date()
date_gmdate in date_php4/date_php4.inc
Like date_date with no GMT conversion.

File

date_php4/date_php4.inc, line 895

Code

function date_date($format, $timestamp = FALSE, $timezone = FALSE) {

  // date($format) will adjust to the server timezone, which may
  // not be right, but we don't use it in this module anywhere and
  // there is no easy way to get it working right without creating
  // circular code.
  if ($timestamp === FALSE) {
    return $is_gmt ? @gmdate($format) : @date($format);
  }
  if ($timezone === FALSE) {
    $timezone = date_default_timezone_name();
  }

  // Anything with a timezone other than UTC needs to be forced to the
  // low level function to compute the timezone offset correctly.
  $is_gmt = $timezone == 'UTC' ? TRUE : FALSE;
  if (abs($timestamp) <= 0x7fffffff) {

    // Below PHP 5.2 in windows, must be positive integer
    if ($timestamp >= 0 && $is_gmt) {
      return @gmdate($format, $timestamp);
    }
    elseif ($timestamp >= 0 && variable_get('date_use_server_zone', FALSE)) {
      return @date($format, $timestamp);
    }
  }
  return _date_date($format, $timestamp, $timezone);
}