<div>After all search, I found it really difficult to deal with date. I am trying to store the date in MySql table as varchar type and placeholder as %s.</div>
<div> </div>
<div>However I need two functions to convert date from array format to string format (required while storing into table) and string format to array format (Required while showing it in form).</div>
<div> </div>
<div>The below code does that for me.</div>
<div> </div>
<div> </div>
<div><strong><em>function dateArrToStr(&amp;$customDateArr)<br>{<br> $strDate = t($customDateArr[&#39;day&#39;]).t(&#39;- &#39;).t($customDateArr[&#39;month&#39;]).t(&#39;-&#39;) . t($customDateArr[&#39;year&#39;]);<br> return $strDate;<br>
}</em></strong></div>
<div><strong><em></em></strong> </div>
<div><strong><em></em></strong> </div>
<div><strong><em>function dateStrToArr (&amp;$customDateStr, $length)<br>{<br>    $convDate = array();<br> $index = 0;<br> $customToken = t(&#39;&#39;);<br> $dashPosition = 0;<br> <br> for($index = 0; $index &lt; $length; $index++)<br>
 {<br>  if($customDateStr[$index] == t(&#39;-&#39;))<br>  {<br>   if($dashPosition == 0)<br>   {<br>    //Set the day<br>    $dashPosition++;<br>       $convDate[&#39;day&#39;] =  $customToken;<br>   }<br>   else if ($dashPosition == 1)<br>
   {<br>    //Set the month<br>    $dashPosition++;<br>    $convDate[&#39;month&#39;] = $customToken;<br>   }<br>   $customToken = t(&#39;&#39;);<br>  }<br>  else<br>  {<br>   $customToken = t($customToken) . t($customDateStr[$index]) ;<br>
  }<br> }<br> //Set year<br> $convDate[&#39;year&#39;] = $customToken;<br> return $convDate;<br>}</em></strong></div>
<div> </div>
<div> </div>
<div>Regards</div>
<div>Austin<br><br></div>
<div class="gmail_quote">On Mon, Mar 28, 2011 at 8:36 AM, Austin Einter <span dir="ltr">&lt;<a href="mailto:austin.einter@gmail.com">austin.einter@gmail.com</a>&gt;</span> wrote:<br>
<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">
<div>Hi All</div>
<div>I have a date field in my form.</div>
<div>How do I store/retreive the value into/from MySQL.</div>
<div> </div>
<div>On google search, I saw people are suggesting to use either &quot;int&quot; or &quot;datetime&quot; type.</div>
<div>Please suggest which one needs to be used.</div>
<div> </div>
<div>If I use int (I hope core uses int), while storing can I just store &quot;form[&#39;values&#39;][&#39;date1&#39;]&quot; as %d and while retreivin, what are the related apis to convert back to date.</div>
<div> </div>
<div>Regards</div>
<div>Austin.</div><font color="#888888">
<div> </div>
<div> </div></font></blockquote></div><br>