title: Paypal API (NVP) TransactionSearch giving error 10004 - Start Date is invalid
body: <p>Okay, so the following code is giving me the above error "Start date is invalid". Even when I have verified from various sources that it is a valid and well formatted start date. The res of the code has no problem since it is successfully returning the correct balance. I have searched every where but can't find a solution to this. Please help. Thanks!</p>
  
  <pre><code>class Paypal
  {
  /**
   * API Version
   */
  const VERSION = 51.0;
  
  /**
   * List of valid API environments
   * @var array
   */
  private $allowedEnvs = array(
      'beta-sandbox',
      'live',
      'sandbox'
  );
  
  /**
   * Config storage from constructor
   * @var array
   */
  private $config = array();
  
  /**
   * URL storage based on environment
   * @var string
   */
  private $url;
  
  /**
   * Build PayPal API request
   * 
   * @param string $username
   * @param string $password
   * @param string $signature
   * @param string $environment
   */
  public function __construct($username, $password, $signature, $environment = 'live')
  {
      if (!in_array($environment, $this-&gt;allowedEnvs)) {
      throw new Exception('Specified environment is not allowed.');
      }
      $this-&gt;config = array(
      'username'    =&gt; $username,
      'password'    =&gt; $password,
      'signature'   =&gt; $signature,
      'environment' =&gt; $environment
      );
  }
  
  /**
   * Make a request to the PayPal API
   * 
   * @param  string $method API method (e.g. GetBalance)
   * @param  array  $params Additional fields to send in the request (e.g. array('RETURNALLCURRENCIES' =&gt; 1))
   * @return array
   */
  public function call($method, array $params = array())
  {
      $fields = $this-&gt;encodeFields(array_merge(
      array(
          'METHOD'    =&gt; $method,
          'VERSION'   =&gt; self::VERSION,
          'USER'      =&gt; $this-&gt;config['username'],
          'PWD'       =&gt; $this-&gt;config['password'],
          'SIGNATURE' =&gt; $this-&gt;config['signature']
      ),
      $params
      ));
  
      $ch = curl_init();
      curl_setopt($ch, CURLOPT_URL, $this-&gt;getUrl());
      curl_setopt($ch, CURLOPT_POST, count($fields));
      curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($fields));
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
      $response = curl_exec($ch);
      if (!$response) {
      throw new Exception('Failed to contact PayPal API: ' . curl_error($ch) . ' (Error No. ' . curl_errno($ch) . ')');
      }
      curl_close($ch);
      parse_str($response, $result);
      return $this-&gt;decodeFields($result);
  }
  
  /**
   * Prepare fields for API
   * 
   * @param  array  $fields
   * @return array
   */
  private function encodeFields(array $fields)
  {
      return array_map('urlencode', $fields);
  }
  
  /**
   * Make response readable
   * 
   * @param  array  $fields
   * @return array
   */
  private function decodeFields(array $fields)
  {
      return array_map('urldecode', $fields);
  }
  
  /**
   * Get API url based on environment
   * 
   * @return string
   */
  private function getUrl()
  {
      if (is_null($this-&gt;url)) {
      switch ($this-&gt;config['environment']) {
          case 'sandbox':
          case 'beta-sandbox':
          $this-&gt;url = "https://api-3t.".$this-&gt;config['environment'].".paypal.com/nvp";
          break;
          default:
          $this-&gt;url = 'https://api-3t.paypal.com/nvp';
      }
      }
      return $this-&gt;url;
  }
  }
  $paypal = new Paypal('xxxxxxxxxxxxxxxxxxxxxx', 'xxxxxxxxxxxxxxxxxx', 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx');
  
  
  
  print_r($paypal-&gt;call('TransactionSearch', array("STARTDATE"=&gt;"2016-02-24T00:00:00Z")));
  </code></pre>