Hi,
I have a table with a timedate collumn. I want to get the text of the article and its creation date, than to output them on my page.
How can I just get only the date value from a query or php script manupulation?

Recommended Answers

All 4 Replies

SELECT DATE(datetimecolumn) AS `date` FROM `table`

Misread your question. I'll leave my answer here for those who are looking for the same, but with a timestamp column

You can either select the timestamp from MySQL returning it in the format you desire - see FROM_UNIXTIME

SELECT FROM_UNIXTIME(`timestamp`, '%Y %D %M') AS `date FROM `table`;
-- 2007 30th November

Or, you can convert the timestamp into a date using PHP - see date

echo date('Y jS M', $timestamp);
// 2007 30th November

At first thank you for your help.
Maybe I was not clear in my description.
I am using this query: SELECT * FROM scms_latest_news;
The table scms_latest_news has 3 collunms id, content, add_date

$query = "SELECT * FROM scms_latest_news;";

I want to output the content is : $row['content'] . "Creation date:" . $row['???????']

SELECT *,DATE(add_date) AS `date` FROM `scms_latest_news`

Then you can use:

$row['date']
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.