If you are storing birthdates, you probably want to use DATETIME in the schema instead of INT. INT would require the date be stored as a unix timestamp, which is only valid after the year 1970, and birthdays are likely to exist before this date.<div>
<br></div><div>DATETIME accepts strings formatted like </div><div><br></div><div>YYYY-MM-DD HH:MM:SS</div><div><br></div><div>and generally you store the UTC date and convert the timezone later.</div><div><br></div><div>See some of the functions in the Date API module for help in conversion (comes with Date module). Some of these utilities have been moved into core in Drupal 7.<br>
<div><div><br clear="all"><div><br></div><div class="gmail_quote">On Mon, Mar 28, 2011 at 9:27 AM, Brett Evanson <span dir="ltr"><<a href="mailto:brettev@gmail.com">brettev@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
You might want to look at the strtotime function in php. I believe it<br>
would take that date and turn it into a Unix epoch number (i think<br>
that's what you're looking for)<br>
<br>
Brett Evanson<br>
<div><div></div><div class="h5"><br>
<br>
<br>
<br>
<br>
On Mon, Mar 28, 2011 at 9:15 AM, Austin Einter <<a href="mailto:austin.einter@gmail.com">austin.einter@gmail.com</a>> wrote:<br>
> Hi All<br>
> I have date field, I am storing it as "int" in table.<br>
> When I checked the table in database, the value shows as 1.<br>
><br>
> My code is as below.<br>
><br>
> 'INSERT INTO {rs_table} ( uid, name, qualification, email, altemail, phone,<br>
> altphone, dob, yrsofexp, prefworkloc) '<br>
> ."VALUES (%d, '%s', '%s', '%s', '%s', '%s', '%s', '%d', '%d', '%s')",<br>
> $user->uid,<br>
> $form_state['values']['persname'],<br>
> $form_state['values']['hqualif'],<br>
> $form_state['values']['email'],<br>
> $form_state['values']['altemail'],<br>
> $form_state['values']['phone'],<br>
> $form_state['values']['altphone'],<br>
> $form_state['values']['birthdate'],<br>
> $form_state['values']['yearsexp'],<br>
> $form_state['values']['prefloc']<br>
> );<br>
><br>
> Whats the wrong here, is there any API I have to make use of to convert from<br>
> date to int value??<br>
><br>
> Regards<br>
> Austin<br>
><br>
><br>
><br>
> On Mon, Mar 28, 2011 at 8:36 AM, Austin Einter <<a href="mailto:austin.einter@gmail.com">austin.einter@gmail.com</a>><br>
> wrote:<br>
>><br>
>> Hi All<br>
>> I have a date field in my form.<br>
>> How do I store/retreive the value into/from MySQL.<br>
>><br>
>> On google search, I saw people are suggesting to use either "int" or<br>
>> "datetime" type.<br>
>> Please suggest which one needs to be used.<br>
>><br>
>> If I use int (I hope core uses int), while storing can I just<br>
>> store "form['values']['date1']" as %d and while retreivin, what are the<br>
>> related apis to convert back to date.<br>
>><br>
>> Regards<br>
>> Austin.<br>
>><br>
>><br>
><br>
</div></div>> --<br>
> [ Drupal support list | <a href="http://lists.drupal.org/" target="_blank">http://lists.drupal.org/</a> ]<br>
><br>
<font color="#888888">--<br>
[ Drupal support list | <a href="http://lists.drupal.org/" target="_blank">http://lists.drupal.org/</a> ]<br>
</font></blockquote></div><br></div></div></div>