Skip to main content

format_date()

public static function format_date( $gmt_datetime, $is_human=true, $date_format='', $include_time=true )

Formats the given date/time for display.

Since:

  • unknown
  • 2.4.23 (Fixed empty default date and time options.)

Source: common.php:3363

Parameters

NameTypeDefaultDescription
$gmt_datetimestringThe UTC date/time value to be formatted.
$is_humanbooltrueIndicates if a human readable time difference such as "1 hour ago" should be returned when within 24hrs of the current time. Defaults to true.
$date_formatstring''The format the value should be returned in. Defaults to an empty string; the date format from the WordPress general settings, if configured, or Y-m-d.
$include_timebooltrueIndicates if the time should be included in the returned string. Defaults to true; the time format from the WordPress general settings, if configured, or H:i.

Returns

  • string