I use CURRENT_TIMESTAMP with DATETIME as the column type. 
Thus just modify s/time()/CURRENT_TIMESTAMP/ should fix your woes.

Joel
http://cow.whyi.org


On Thu, 20 Mar 2003, Robert Maurency wrote:

> I've got a MySQL question for you.
> 
> Is the php value <?echo time();?> suitable for a MySQL timestamp field?
> 
> The reason I ask is because I'm getting an odd result in my web content
> publishing site.
> 
> I'm grabbing form data from a query string and inserting it into MySQL.
> (NewsDate is a MySQL timestamp field)
> 
>         $query = "INSERT INTO News(Headline, Story, Status, Author,
> NewsDate) VALUES('" . $_GET['Headline'] . "', '" . 
$_GET['Story'] . "', '" .
> $_GET['Status'] . "', '" . $_GET['Author'] . "', '" . time() . "')";
> 
> This query works fine, but when I view the information on my 
news page the
> date returned ($row->NewsDate) is:
> 
>         00000000000000
> 
> Which formatted with this function <?echo date("h:i d M Y",
> $row->NewsDate);?> returns:
> 
>         11:00 01 Jan 1970
> 
> If I leave the time() function out of my insert statement then 
the returned
> value is:
> 
>         20030320084636 or (02:14 19 Jan 2038)
> 
> Does anyone know what is going on here?
> Any help, much appreciated.
> Rob
> (I'm making the tranistion between ASP & Access to PHP and MySQL and am
> having a tough time with this GUI-less database.)
>        
> 
> *************************************************************
> This mail, including any attached files may contain
> confidential and privileged information for the sole
> use of the intended recipient(s). Any review, use, 
> distribution or disclosure by others is strictly prohibited.
> If you are not the intended receipient (or authorised to 
> receive information for the recipient), please contact 
> the sender by reply e-mail and delete all copies of
> this message.
> *************************************************************
> 
-- 
SLUG - Sydney Linux User's Group - http://slug.org.au/
More Info: http://lists.slug.org.au/listinfo/slug

Reply via email to