Re: Forms and MySql date
| From: | Frank Keessen | Date: | Fri, 21 Feb 2003 06:20:46 +0000 |
| Subject: | Re: Forms and MySql date | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-136458@lists.php.net to get a copy of this message | ||
Hi,
You can let the users enter a date as 20-02-2003 into a textfield with the
name $userdate
Then you can use this function to convert it;
$date_array = split("-", $userdate);
$mysqldate = $date_array[2]."-".$date_array[1]."-".$date_array[0];
Store $mysqldate into the database!
Regards,
Frank
----- Original Message -----
From: "Philip Hallstrom" <philip@adhesivemedia.com>
To: "Mike Tuller" <php@ce.anoka.k12.mn.us>
Cc: "php mailing list list" <php-general@lists.php.net>
Sent: Thursday, February 20, 2003 11:48 PM
Subject: [PHP] Re: Forms and MySql date
> You could use the TO_DATE function to convert that text string into a
> date, or reformat it in PHP to yyyy-mm-dd which mysql will take
> automatically (at least I think so)
>
> On Thu, 20 Feb 2003, Mike Tuller wrote:
>
> > I have a form that I want to enter a date into a MySql database. I
> > currently have the column in the database set as Date, and can't seem
> > to get the date I enter into the text field to go into the database
> > using the format yymmdd. I could change the column to varchar, and then
> > it would enter, but this will be a database that I want to keep track
> > of purchases, and if it is entered in as text, I wouldn't be able to do
> > calculations such as showing how old something is.
> >
> > How can I have a text field where a person enters the date and have
> > that information entered into the database?
> >
> > Mike
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>