Jump to content

Am I using convert() wrong?


nicolanicola

Recommended Posts

I am extremely new to this, so please bear with me if I don't make sense.

 

In a php script, I add a datestamp to a field by using the now() function.

 

I am retrieving this field now from db, I have successfuly managed to get the date and convert it - select DATE_FORMAT(date,'%d-%m-%Y') as postedDate.

 

But I can't get the time at all. Can someone please help? I've tried using convert but I think I'm doing it wrong, because my php code just exits and the html then continues, after the following select statement.  If I take convert out it works, so I figure something is wrong with the convert statement.

 

mysql_query("SELECT asset_id, name, email, website ,comment, CONVERT(varchar(10), date, 108) as theTime, DATE_FORMAT(date,'%d-%m-%Y') as postedDate FROM Comment WHERE asset_id='lbi-type' ORDER BY date", $connection);

Link to comment
https://forums.phpfreaks.com/topic/198064-am-i-using-convert-wrong/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.