You are here: Re: FormatDateTime Revisited « PHP Programming Language « IT news, forums, messages
Re: FormatDateTime Revisited

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация