skip to Main Content

I am exporting order data from woocommerce. For the order date, I am using:

// Get order
$order = wc_get_order($id);

// Get order date
$orderdate = $order->order_date;

Now the order date appears in de xml file as "2020-10-15 06:53:36". I would only like to display the date and not the time. I have tried adding format(‘Y-m-d’):

// Get order date
$orderdate = $order->format('Y-m-d')->order_date;

Doesnt work either.

2

Answers


  1. You should make use of get_date_created()

    $order->get_date_created()->format('Y-m-d');
    
    Login or Signup to reply.
  2. You should try echo date('Y-m-d', strtotime($orderdate));

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search