Instead of the user choosing from hardcoded date formats in admin, it would be nice if we could enter any date format, using the syntax of the PHP strftime function. The date would already be formatted according to locale settings, there'd be no need to translate month names etc.

Comments

Mirrorball’s picture

Here is how I think format_date should be:

function format_date($timestamp, $type = 'medium', $format = '', $timezone = NULL) {
  if (!isset($timezone)) {
    global $user;
    if (variable_get('configurable_timezones', 1) && $user->uid && strlen($user->timezone)) {
      $timezone = $user->timezone;
    }
    else {
      $timezone = variable_get('date_default_timezone', 0);
    }
  }

  $timestamp += $timezone;

  switch ($type) {
    case 'small':
      $format = variable_get('date_format_short', '%m/%d/%Y - %H:%M');
      break;
    case 'large':
      $format = variable_get('date_format_long', '%A, %B %e, %Y - %H:%M');
      break;
    case 'custom':
      // No change to format
      break;
    case 'medium':
    default:
      $format = variable_get('date_format_medium', '%a, %m/%d/%Y - %H:%M');
  }
  return gmstrftime($format, $timestamp);
}
LAsan’s picture

Version: x.y.z » 7.x-dev

Feature request moving to cvs.

steven jones’s picture

Status: Active » Closed (duplicate)

D7 has this in core now!