classes/fields/datetime.php
public function convert_date( $value, $new_format, $original_format = '', $return_timestamp = false ) {

		if ( empty( $original_format ) ) {
			$original_format = static::$storage_format;
		}

		$date = '';

		if ( ! empty( $value ) && ! in_array( $value, array( '0000-00-00', '0000-00-00 00:00:00', '00:00:00' ), true ) ) {
			$date = $this->createFromFormat( $original_format, (string) $value, $return_timestamp );

			if ( $date instanceof DateTime ) {
				$value = $date->format( $new_format );
			} elseif ( false !== $date ) {
				$date = strtotime( (string) $value );

				$value = date_i18n( $new_format, $date );
			}
		} else {
			$value = date_i18n( $new_format );
		}

		// Return timestamp conversion result instead
		if ( $return_timestamp ) {
			return $date;
		}

		return $value;
	}
public function convert_date( $value, $new_format, $original_format = '', $return_timestamp = false ) {

		if ( empty( $original_format ) ) {
			$original_format = static::$storage_format;
		}

		$date = '';

		if ( ! empty( $value ) && ! in_array( $value, array( '0000-00-00', '0000-00-00 00:00:00', '00:00:00' ), true ) ) {
			$date = $this->createFromFormat( $original_format, (string) $value, $return_timestamp );

			if ( $date instanceof DateTime ) {
				$value = $date->format( $new_format );
			} elseif ( false !== $date ) {
				$date = strtotime( (string) $value );

				$value = date_i18n( $new_format, $date );
			}
		} else {
			$value = date_i18n( $new_format );
		}

		// Return timestamp conversion result instead
		if ( $return_timestamp ) {
			return $date;
		}

		return $value;
	}
public function convert_date ( $ value , $ new_format , $ original_format = '' , $ return_timestamp = false ) { if ( empty ( $ original_format ) ) { $ original_format = static :: $ storage_format ; } $ date = '' ; if ( ! empty ( $ value ) && ! in_array ( $ value , array ( '0000-00-00' , '0000-00-00 00:00:00' , '00:00:00' ) , true ) ) { $ date = $ this -> createFromFormat ( $ original_format , ( string ) $ value , $ return_timestamp ) ; if ( $ date instanceof DateTime ) { $ value = $ date -> format ( $ new_format ) ; } elseif ( false !== $ date ) { $ date = strtotime ( ( string ) $ value ) ; $ value = date_i18n ( $ new_format , $ date ) ; } } else { $ value = date_i18n ( $ new_format ) ; } // Return timestamp conversion result instead if ( $ return_timestamp ) { return $ date ; } return $ value ; }
Convert a date from one format to another.

@param string  $value            Field value.
@param string  $new_format       New format string.
@param string  $original_format  Original format string (if known).
@param boolean $return_timestamp Whether to return the strtotime() or createFromFormat result or not.

@return string|int|boolean|DateTime
Convert a date from one format to another .