0

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.

bytris
  • 61
  • 3

2 Answers2

1

You should make use of get_date_created()

$order->get_date_created()->format('Y-m-d');
Alexandre Elshobokshy
  • 10,720
  • 6
  • 27
  • 57
0

You should try echo date('Y-m-d', strtotime($orderdate));