Quote:
|
My problem is how to I get it to submit into a field on a MySQL database I have named "General Date".
|
ok dude, this is gonna be quick and maybe painful, i wanna go to bed and I'm ill! But i had the same problem once too (i'm sure we all did)
First off, you don't have to enter a certain date into SQL if it's the same date as today, you can simply put CURDATE( ). If it's not todays date, then SQL demands you have the date in an american way (so YEAR-MON-DAY or YYYY-MM-DD).
So, if you want to convert a date into the SQL format, we can do this:
PHP Code:
/* Note: gmdate = the date at GMT (i.e. England)
Note: Y = 4 digit year, m= numerical month, with 0s, d= numerical day, with 0s
Note: month, day, year should be replaced with the month, day, year you wish to be
changed into the SQL format, these should be in NUMERICAL form. */
$SQLDate = gmdate("Y-m-d", mktime(0, 0, 0, month, day, year));
So, therefore, it makes sense that to change a date FROM SQL format to whatever desired format you need, we do this:
PHP Code:
/* new addition here is the list and split, this will split the SQL style YYYY-MM-DD into three
variables: $year, $month, $day. The only variable you need to define is $date, which
would be the SQL date, from the database. */
list($year, $month, $day) = split('[/.-]', $date);
$NiceDate = gmdate("d F Y", mktime(0, 0, 0, $month, $day, $year));
/* This outputs something like: 04 April 2005 i believe */
As for:
Quote:
|
Furthermore how would I code for a search to list say only the Month or day or best yet a string between say March 10 and March 17, for an example.
|
Well, SQL has it's own QUERY details that can help here, search for some article about them, it will be faster than using PHP and a **** of a lot easier!
Hope this helps, please write back!