wc_format_datetime function

This commit is contained in:
Mike Jolley 2017-03-10 16:29:42 +00:00
parent 05e6c506ce
commit 804573028d
1 changed files with 18 additions and 0 deletions

View File

@ -1023,3 +1023,21 @@ function wc_format_dimensions( $dimensions ) {
return apply_filters( 'woocommerce_format_dimensions', $dimension_string, $dimensions );
}
/**
* Format a date for output.
*
* @since 2.7.0
* @param WC_DateTime $date
* @param string $format Defaults to the wc_date_format function if not set.
* @return string
*/
function wc_format_datetime( $date, $format = '' ) {
if ( ! $format ) {
$format = wc_date_format();
}
if ( ! is_a( $date, 'WC_DateTime' ) ) {
return '';
}
return $date->date_i18n( $format );
}