I assume you&#39;re using Drupal 6. See the date_api.module functions like date_make_date() which will return a Date object that can be formatted with date_format_date().<div><br></div><div>Your schema type should be DATETIME or DATE <a href="http://dev.mysql.com/doc/refman/5.0/en/datetime.html">http://dev.mysql.com/doc/refman/5.0/en/datetime.html</a> </div>
<meta charset="utf-8"><div><br></div><div>You probably want to have something like this to INSERT/UPDATE the db.</div><div><br></div><div>$date_array[&#39;year&#39;] . &#39;-&#39; . $date_array[&#39;month&#39;] . &#39;-&#39; . $date_array[&#39;day&#39;] . &#39; 00:00:00&#39;;</div>
<div><br></div><div>Then, when you SELECT the value you can do something like this.</div><div><br></div><div>$displayed_date = date_format_date(date_make_date($value, &#39;UTC&#39;), &#39;custom&#39;, &#39;m/d/Y&#39;);</div>
<meta charset="utf-8"><div><div><br></div><div><meta charset="utf-8"><div>Non-language specific strings do not need to be handled with t(), too. :)</div></div><div><br></div><div>Also, is there a reason you&#39;re not using Content Profile with Date module to accomplish your task?</div>
<div><a href="http://drupal.org/project/content_profile">http://drupal.org/project/content_profile</a></div><div><a href="http://drupal.org/project/date">http://drupal.org/project/date</a></div><div><br></div><div><br><div class="gmail_quote">
On Mon, Mar 28, 2011 at 10:49 PM, Austin Einter <span dir="ltr">&lt;<a href="mailto:austin.einter@gmail.com">austin.einter@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<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 class="h5">
<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" target="_blank">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>
</div></div><br>--<br>
[ Drupal support list | <a href="http://lists.drupal.org/" target="_blank">http://lists.drupal.org/</a> ]<br></blockquote></div><br></div></div>