|
Posted by John K on 09/27/28 11:37
I have the date and time fields separate at the moment. this is what
I'm trying to do...
$dateMerge = $_POST['month']. " " . $_POST['day'] . ", " .
$_POST['year'] ;
$timeMerge = $_POST['Time_Hour'] . ":" . $_POST['Time_Minute'] .
$_POST['Time_AMPM'];
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "gigAdd"))
{
$insertSQL = sprintf("INSERT INTO tbl_gigs (fld_gig_Title,
fld_gig_Date, fld_gig_Time, fld_gig_Comments) VALUES (%s, %s, %s, %s)",
GetSQLValueString($_POST['gigTitle'], "text"),
date("Y-m-d", ($dateMerge)),
GetSQLValueString($timeMerge, "text"),
GetSQLValueString($_POST['comments'], "text"));
it's not working, the date is still messed up.
Adam Plocher wrote:
> PHP has some great date functions for formatting dates however you
> could possibly want. First take a look at www.php.net/date for a list
> of formats.
>
> Notice that the second (optional) parameter to the date function is a
> timestamp parameter. You must convert your date/time into a unix
> timestamp but this can easily be achieved with the strtotime() function
> (www.php.net/strtotime).
>
> So basically you would want to do:
>
> echo date("Y-m-d H:i:s", strtotime("December 25, 2005 11:55 PM"));
> // this should return 2005-12-25 23:55:00 - this is the format I
> usually use when inserting into MySQL
>
> Note that strtotime should be able to take in just about ANY format of
> date and time.
Navigation:
[Reply to this message]
|