Search code examples
phpdatewoocommercereferencenumbers

Displaying WooCommerce get_date_created() as ddmmyyyy, not yyyy-mm-dd+time


I'm trying to display a reference number with order on hold for Direct Bank Transactions with WooCommerce. I added

<p><?php esc_html_e( 'Za referenco (sklic) uporabite "SI 00 ' . $order->get_order_number() . $order->get_date_created() . ' ". ', 'woocommerce' ); ?></p>

to customer-on-hold-order.php (which I copied to my child theme. It works, but the result is shown as

Za referenco (sklic) uporabite "SI 00 48522021-12-27T09:10:49+01:00 "., 

and in this case I would need it shown as

Za referenco (sklic) uporabite "SI 00 485227122021 ".

How can I modify the displayed date?

Kind regards


Solution

  • Use date() to convert the date to what you want

    <p>
        <?php esc_html_e( 'Za referenco (sklic) uporabite "SI 00 ' .
            $order->get_order_number() . 
            date('dmY',strtotime($order->get_date_created())) . 
            ' ". ', 'woocommerce' ); 
        ?>
    </p>