Home > Archive > PHP DB > July 2004 > php mysql dates
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
| Irm Jr 2004-07-28, 8:56 pm |
|
Hi all, currently I have a form which prompts for the user to choose a
date. The dropdown lists are stored into variables:
$month //e.g. January, February, ...
$day //e.g 1 - 31
$year //e.g. 2004 (four digits)
then combined into
$articleDate
How can I manipulate this variable to be in such a format that I can
insert the information into a DATE column in a mySQL database.
Dates are a bit of a mystery to me as PHP and MySQL handle them
differently. Your help is appreciated.
Thanks
| |
| J.T. Moore 2004-07-30, 8:55 am |
| You can use something like
$articleDate= date ("Y-m-d 00:00:00",strtotime($day ." " . $month . " "
.. $year));
If $day = 10 and $month = "January" and $year = 2004
then $articleDate will be set to "2004-01-10 00:00:00"
Then you can insert $articleDate into a datetime field in mysql.
"Irm Jr" <irmjr@CART.ORG> wrote in message
news:B4A64F3A0C84B346BEAB2513306F10FC051
CA9@fatexchange.CART.ADS...
Hi all, currently I have a form which prompts for the user to choose a
date. The dropdown lists are stored into variables:
$month //e.g. January, February, ...
$day //e.g 1 - 31
$year //e.g. 2004 (four digits)
then combined into
$articleDate
How can I manipulate this variable to be in such a format that I can
insert the information into a DATE column in a mySQL database.
Dates are a bit of a mystery to me as PHP and MySQL handle them
differently. Your help is appreciated.
Thanks
|
|
|
|
|