mga_ka_php Posted February 21, 2009 Share Posted February 21, 2009 is it possible that i could get and convert the content of a column. example. id message 1 have a message for you last 12993234 the 12993234 is a timestamp for example. i want to have a sql statement that will get that timestamp and convert it to a date example: SELECT id, message, (statement here) AS date FROM table1 id message date 1 have a message for you last 12993234 2009-02-16 12993234 ---> 2009-02-16 the timestamp was converted to a date format of yyyy-mm-dd is that possible? if possible how do i do that? Link to comment https://forums.phpfreaks.com/topic/146221-how-to-get-and-convert/ Share on other sites More sharing options...
mjahkoh Posted February 21, 2009 Share Posted February 21, 2009 http://www.randomsnippets.com/2008/10/05/how-to-convert-mysql-timestamp-to-php-date-type/ Link to comment https://forums.phpfreaks.com/topic/146221-how-to-get-and-convert/#findComment-767666 Share on other sites More sharing options...
mga_ka_php Posted February 21, 2009 Author Share Posted February 21, 2009 i want to directly convert via the sql statement Link to comment https://forums.phpfreaks.com/topic/146221-how-to-get-and-convert/#findComment-767756 Share on other sites More sharing options...
corbin Posted February 21, 2009 Share Posted February 21, 2009 DATE_FORMAT And you will need to convert the unix timestamp to DATETIME first. So something like: DATE_FORMAT('%Y-%m-%d', FROM_UNIXTIME(column_name)); I think that DATE might be in that format, so you might just be able to convert it to a date. Link to comment https://forums.phpfreaks.com/topic/146221-how-to-get-and-convert/#findComment-767866 Share on other sites More sharing options...
PFMaBiSmAd Posted February 21, 2009 Share Posted February 21, 2009 FYI: FROM_UNIXTIME has a form where you can do that all at once - FROM_UNIXTIME(unix_timestamp,format) Link to comment https://forums.phpfreaks.com/topic/146221-how-to-get-and-convert/#findComment-767870 Share on other sites More sharing options...
corbin Posted February 23, 2009 Share Posted February 23, 2009 Oh hrmmm.... Nifty! Link to comment https://forums.phpfreaks.com/topic/146221-how-to-get-and-convert/#findComment-768877 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.