title: Magento programmatically create order with custom option of type "date"
body: <p>i'm trying to automatically create new orders in magento based from data given by textfiles coming from somewhere. This is the basic code i'm using:</p>
  
  <pre><code>$product = Mage::getModel('catalog/product')-&gt;load($productId);
  $request = new Varien_Object();
  $request-&gt;setData(array(
      'product' =&gt; $product-&gt;getId(),
      'qty' =&gt; 1,
      'options' =&gt; array(
          30 =&gt; 'some text...',
          8 =&gt; 'some other text...',
          7 =&gt; date('Y-m-d H:i:s')
      )
  ));
  $quote = Mage::getModel('sales/quote')
      -&gt;setStoreId($storeId)
      -&gt;setIsMultiShipping(false)
      -&gt;setCheckoutMethod('guest')
      -&gt;setCustomerId(null)
      -&gt;setCustomerEmail($customerEmail)
      -&gt;setCustomerIsGuest(true)
      -&gt;setCustomerGroupId(Mage_Customer_Model_Group::NOT_LOGGED_IN_ID);
  
  $quote-&gt;addProduct($product, $request);
  // ...the interesting part ends here
  </code></pre>
  
  <p>Custom option with id "7" is of type "date" (configured from Magento's web backend), and this is definitely what causes problems: this snippet works well when custom option 7 is changed to type "text field".</p>
  
  <p>If i inspect the contents of the <code>$quote</code> object after calling <code>addProduct()</code>, i see that the value of custom option 7 is not a date string, as expected, but a single digit (which appears to be exactly the first digit of the date formatted as <code>Y-m-d H:i:s</code>, thus the first digit of the year, as i tried with different years).</p>
  
  <p>If i change the type of option 7 to text, the whole date string is correctly saved inside the <code>$quote</code> object.</p>
  
  <p>As additional information, if i let the script go on through all the order-creating process, what i get is an exception that says:</p>
  
  <pre><code>Unsupported ISO8601 format (2)
  </code></pre>
  
  <p>where the number <code>2</code> is the first digit of the date i was talking before. So i tried to use the <code>iso8601</code> format:</p>
  
  <pre><code>7 =&gt; date('c')
  </code></pre>
  
  <p>with no effect at all.</p>
  
  <p>The stack trace of that exception is:</p>
  
  <pre><code>#0 app/code/core/Zend/Date.php(1091): Zend_Date-&gt;_calculate('set', '2', 'c', 'it_IT')
  #1 app/code/core/Zend/Date.php(210): Zend_Date-&gt;set('2', 'c', 'it_IT')
  #2 app/code/core/Mage/Core/Model/Locale.php(494): Zend_Date-&gt;__construct('2', 'c', Object(Zend_Locale))
  #3 app/code/core/Mage/Catalog/Model/Product/Option/Type/Date.php(167): Mage_Core_Model_Locale-&gt;date('2', 'c', NULL, false)
  #4 app/code/core/Mage/Catalog/Model/Product/Type/Abstract.php(620): Mage_Catalog_Model_Product_Option_Type_Date-&gt;getFormattedOptionValue('2')
  #5 app/code/core/Mage/Sales/Model/Convert/Quote.php(141): Mage_Catalog_Model_Product_Type_Abstract-&gt;getOrderOptions(Object(Mage_Catalog_Model_Product)) 
  #6 app/code/core/Mage/Sales/Model/Service/Quote.php(170): Mage_Sales_Model_Convert_Quote-&gt;itemToOrderItem(Object(Mage_Sales_Model_Quote_Item))
  #7 app/code/core/Mage/Sales/Model/Service/Quote.php(249): Mage_Sales_Model_Service_Quote-&gt;submitOrder()
  #8 wbs-import-orders.php(309): Mage_Sales_Model_Service_Quote-&gt;submitAll()
  #9 {main}
  </code></pre>
  
  <p>So, how to make this custom option of type "date" accept date strings? Is it even correct to pass date strings that way?</p>
  
  <p>Thank you all!</p>