function format_date

7.x theme.inc format_date($timestamp = 0, $format = "standard", $custom = "")
6.x theme.inc format_date($timestamp = 0, $format = "standard", $custom = "")
4.x theme.inc format_date($timestamp, $format = "standard", $custom = "")
5.x theme.inc format_date($timestamp = 0, $format = "standard", $custom = "")

Format a timestamp using the date command. TODO: Make the formats something which can be controlled through the settings.

Available formats:

  • standard
  • short
  • pretty
  • just_date
18 calls to format_date()
admin_display_watchdog in modules/admin/admin.module
Displays recent watchdog entries, from the watchdog table
admin_display_watchdog_entry in modules/admin/admin.module
Display the details of a particular watchdog entry, specified by its table id.
advise_display_history in modules/advise/advise.history.inc
Displays the history tab on screen.
advise_popup_display_summary in modules/advise/advise.history.inc
Displays the printable advising summary.
comments_render_comment in modules/comments/comments.module
Display the comment array in a pretty way.

... See full list

File

includes/theme.inc, line 34

Code

function format_date($timestamp = 0, $format = "standard", $custom = "") {

  if (!is_numeric($timestamp)) {
    $timestamp = 0; // make sure it's numeric.
  }

  if ($timestamp == 0) {
    $timestamp = strtotime("now");
  }


  $f = "";
  if ($format == "standard") {
    $f = "n/d/Y h:i:sa";
  }

  if ($format == "short") {
    $f = "n/d/Y - g:ia";
  }

  if ($format == "pretty") {
    $f = "F jS, Y, g:ia";
  }

  if ($format == "just_date") {
    $f = "F jS, Y";
  }

  if ($custom != "") {
    $f = $custom;
  }

  return date($f, $timestamp);


}