Forum Moderators: coopster

Message Too Old, No Replies

Values for dateline in mysql

         

turbohost

9:11 am on Sep 21, 2003 (gmt 0)

10+ Year Member



Hi,

I'm rather new to mysql :->

I've built a table to show the latest news. It has the columns 'newsid','title','body' and 'dateline'. I have some troubles with this latter column because I don't know what value I've got to fill in there to show the date of the latest post. It has to show the date when the news has been published in the database.

Hope someone can help me.

Philip

mogwai

11:14 am on Sep 21, 2003 (gmt 0)

10+ Year Member



Hi,

If you are storing news articles I would imagine that you would want to use the DATETIME datatype. This will store the date values in MySQL in this format:

0000-00-00 00:00:00
YYYY-MM-DD

Then you can use the NOW() MySQL function to insert the current date/time to this field when each news record is added.

Hope this helps

turbohost

2:09 pm on Sep 21, 2003 (gmt 0)

10+ Year Member



Thx. It gives the output 31 Dec 1969. I've seen this more though. Is this a setting on the server itself?

Philip

jatar_k

4:14 pm on Sep 21, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Yes it is a sever date, you might want to read through here

MySQL Date and Time Functions [mysql.com]

mogwai

4:32 pm on Sep 21, 2003 (gmt 0)

10+ Year Member



Is this the date you get from MySQL when you use this query: SELECT NOW();

If that query gives you the correct date, it's a PHP problem. If you are using the date() function to format your result from MySQL make sure that you use strtotime to convert the MySQL output to a UNIX timestamp.