magento2 – invalid date when adding product with custom options(datetime) using REST API


  1. I have a product with a custom option DateTime filed in product options
    Screenshot from 2020-10-07 16-59-54
  2. When I try to place an order using rest API. My order array is given below
$order = array (
  'cartItem' => 
  array (
    'sku' => $product_sku,
    'qty' => 1,
    'quote_id' => $cart_id,
    'product_option' => 
    array (
      'extension_attributes' => 
      array (
        'custom_options' => 
        array (
          0 => 
          array (
            'option_id' => '1',
            'option_value' => '2020-10-15 13:00:00',
          )
      ),
    ),
  ),
    ),
);
  1. My cart response is given below

"{"item_id":4,"sku":"Jessica Pant","qty":1,"name":"Jessica Pant","price":169,"product_type":"simple","quote_id":"3","product_option":{"extension_attributes":{"custom_options":({"option_id":"1","option_value":"2020-10-16 01:00:00"})}}}"

  1. As you can see i have set custom option value(datetime) as ‘2020-10-15 13:00:00‘ in code. But after execute add to cart API code. the date changed to “2020-10-16 01:00:00”

Expected result (*)

"{"item_id":4,"sku":"Jessica Pant","qty":1,"name":"Jessica Pant","price":169,"product_type":"simple","quote_id":"3","product_option":{"extension_attributes":{"custom_options":({"option_id":"1","option_value":"2020-10-15 13:00:00"})}}}"

Actual result (*)

"{"item_id":4,"sku":"Jessica Pant","qty":1,"name":"Jessica Pant","price":169,"product_type":"simple","quote_id":"3","product_option":{"extension_attributes":{"custom_options":({"option_id":"1","option_value":"2020-10-16 01:00:00"})}}}"

My Magento ver. 2.3.4-p2