MySQL Forums
Forum List  »  Newbie

Re: date field in database shows 0000-00-00 00:00:00
Posted by: Felix Geerinckx
Date: August 18, 2005 09:37AM

LaTicca Peeples wrote:

> $date = date("D, d M yyyy, h:ia T");
>
> and my connection includes:
> $sqlquery = "INSERT INTO $table VALUES('$id','$name','$date')";

MySQL expects datetimes in the format 'yyyy-mm-dd hh:mm:ss' in INSERT statements. This is not what you provide.

> my objective is simply to add a date field with the current date and time.
> i want mysql to insert the date for me in the format resulting in this type of output:
> Fri, 19 Aug 2005, 10:23am CST.

See above. If you want to *output* dates in some format, use the DATE_FORMAT() function.
See http://dev.mysql.com/doc/mysql/en/date-and-time-functions.html for formatting options.
(I don't think it does time zones though).

--
felix
Please use BBCode to format your messages in this forum.

Options: ReplyQuote


Subject
Written By
Posted
Re: date field in database shows 0000-00-00 00:00:00
August 18, 2005 09:37AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.