damian0612 Posted April 20, 2009 Share Posted April 20, 2009 Hi I am havng problems converting dates to the format I want. I currently run an SQL query with the following: SELECT CONVERT_TZ(ItemPubDate_t, '+00:00', '+1:00'),ItemTitle,ItemLink,ItemSourceURL FROM feedItems WHERE DATEDIFF(NOW(), `ItemPubDate_t`) = 0 ORDER BY `ItemPubDate_t` DESC I then display the results as follows: echo "<tr><td>$row[0] <A href=$row[3]>$row[1]</A> $linksource</td></tr>";} The field ItemPubDate_t is a datetime field and currently returns the date as '2009-04-20 10:23:20'. I want to convert the ItemPubDate_t to display the time only. I can't do this in the query using: SELECT date_format(`ItemPubDate_t`,'%H:%i') as I am already querying it and adding one hour to times. I would like to know how I can do this using php? Mant thanks Damian Link to comment https://forums.phpfreaks.com/topic/154834-solved-date-formatting/ Share on other sites More sharing options...
Yesideez Posted April 20, 2009 Share Posted April 20, 2009 Best thing to use is PHP's date() function: http://uk.php.net/date $val='2009-04-20 10:23:20'; echo date('H:i:s',strtotime($val)); Link to comment https://forums.phpfreaks.com/topic/154834-solved-date-formatting/#findComment-814312 Share on other sites More sharing options...
damian0612 Posted April 20, 2009 Author Share Posted April 20, 2009 Thank you so much, works perfectly Link to comment https://forums.phpfreaks.com/topic/154834-solved-date-formatting/#findComment-814416 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.