Woocommerce Update Order Notes Date

With the method add_order_note you can add an order note to you order. If you look into the code of this method, you will see that this method is only a wrapper around the wp_insert_comment function from WordPress.

So your problem is, that you want to change the date of the order note. But that is not possible with the method add_order_note. If you look back into the code of that method you will see, that the method has only the
arguments “$note”, “$is_customer_note” and “$added_by_user”. So no date.

The easiest way would be to save the order note not with “add_order_note” but with the function “wp_insert_comment”.

$test_date="2005-08-05 10:41:13";

$note = __("Custom Order Note Here");

$user = get_user_by( 'id', get_current_user_id() );

$data = array(
   'comment_post_ID'      => $order_id,
   'comment_author'       => $user->display_name,
   'comment_author_email' => $user->user_email,
   'comment_author_url'   => '',
   'comment_content'      => $note,

   'comment_agent'        => 'WooCommerce',
   'comment_type'         => 'order_note',
   'comment_parent'       => 0,
   'comment_approved'     => 1,
   'comment_date'         => $test_date,
);

wp_insert_comment($data);