wc_format_datetime

Format a date for output.

Description

(string) wc_format_datetime( (WC_DateTime) $date, (string) $format = '' ); 

Returns (string)

Parameters (2)

0. $date (WC_DateTime)
The date.
1. $format — Optional. (string) => ''
Defaults to the wc_date_format function if not set.

Usage

  1. if ( !function_exists( 'wc_format_datetime' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/wc-formatting-functions.php'; 
  3.  
  4. // The date. 
  5. $date = null; 
  6.  
  7. // Defaults to the wc_date_format function if not set. 
  8. $format = ''; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = wc_format_datetime($date, $format); 
  12.  

Defined (1)

The function is defined in the following location(s).

/includes/wc-formatting-functions.php  
  1. function wc_format_datetime( $date, $format = '' ) { 
  2. if ( ! $format ) { 
  3. $format = wc_date_format(); 
  4. if ( ! is_a( $date, 'WC_DateTime' ) ) { 
  5. return ''; 
  6. return $date->date_i18n( $format );