title: Unable to store Date values in php mysql table that are existing in excel file
body: <p>Hi friends i have a php program where user can upload excel file and data w illbe stored in php database, it works as i expected but the problem is date stored in database is totally different from what i entered in excel</p>
  
  <p>i have used the following codes to read the value from excel..</p>
  
  <pre><code>include("excel/reader.php");
  $data = new Spreadsheet_Excel_Reader();
  $data-&gt;setOutputEncoding('CP1251');
  $data-&gt;read($_POST['upload']);
  
  $conn = mysql_connect("localhost","root","");
  mysql_select_db("mydatabase",$conn);
  $a="TRUNCATE TABLE `sheet`";
  mysql_query($a);
  for ($x = 2; $x &lt;= count($data-&gt;sheets[0]["cells"]); $x++) 
  {
  $inv = $data-&gt;sheets[0]["cells"][$x][1];
  $ds = $data-&gt;sheets[0]["cells"][$x][2];
  $dosstr=strtotime($ds);
  $dos=date('Y-m-d',$dosstr);
  $ptname = $data-&gt;sheets[0]["cells"][$x][3];
  $bal = $data-&gt;sheets[0]["cells"][$x][4];
  $proname = $data-&gt;sheets[0]["cells"][$x][5];
  $sql = "INSERT INTO sheet (INV,DOS,PTNAME,BAL,PROV)
  VALUES ('$inv','$dos','$ptname','$bal','$proname')";
  mysql_query($sql);
  }
  header('location:exsheet2.php');
     ?&gt;
  </code></pre>
  
  <p>i have the following dates stored in excel 
  9/1/2014,
  28/12/2013 ,
  27/9/1991 ,
  1/1/2015 ,
  31/12/2014 ,
  1/1/2012 ,
  5/9/2001 .</p>
  
  <p>but what is being stored in database is
  1970-01-01 ,
  1970-01-01 ,
  1970-01-01 ,
  1970-01-01 ,
  1970-01-01 ,
  1970-01-01 ,
  1970-01-01 ,
  1970-01-01.</p>
  
  <p>please assist me with this issue thanks</p>
  
  <pre><code>for ($x = 2; $x &lt;= count($data-&gt;sheets[0]["cells"]); $x++) 
  {
  $inv = $data-&gt;sheets[0]["cells"][$x][1];
  $ds = $data-&gt;sheets[0]["cells"][$x][2];
  echo $ds;
  echo "&lt;br&gt;";
  if(ctype_digit($ds))
  {
  date_default_timezone_set("Asia/Kolkata");
  $dDate = date_create('1900-01-01');
  $dDate = date_modify($dDate, '+'.($ds-2).' day');
  if($dDate!="")
  {
  $dos = date_format($dDate,'Y-m-d');
  echo "IF".$dos;
  echo "&lt;br&gt;";
  }
  else
  { 
  $dos=$ds; //not able to convert date so show it directly
  echo "Else".$dos;
  echo "&lt;br&gt;";
  }
  }
  else 
  {
  $dos=$ds;
  echo"if Else".$dos;
  }
  
  $ptname = $data-&gt;sheets[0]["cells"][$x][3];
  $bal = $data-&gt;sheets[0]["cells"][$x][4];
  $proname = $data-&gt;sheets[0]["cells"][$x][5];
  $sql = "INSERT INTO sheet (INV,DOS,PTNAME,BAL,PROV)
  VALUES ('$inv','$dos','$ptname','$bal','$proname')";
  mysql_query($sql);
  }
  </code></pre>