Miko Posted December 17, 2010 Share Posted December 17, 2010 Hi, I have in my DB a column with a timestamp as definition. Now I would like to have only the month and year of that column for further use in a form. How can I achieve that? Thanks! Link to comment https://forums.phpfreaks.com/topic/221968-timestamp-from-db/ Share on other sites More sharing options...
MMDE Posted December 17, 2010 Share Posted December 17, 2010 $yearandmonth=substr($timestamp,0,7); $year=substr($timestamp,0,4); $month=substr($timestamp,5,2); Link to comment https://forums.phpfreaks.com/topic/221968-timestamp-from-db/#findComment-1148603 Share on other sites More sharing options...
Pikachu2000 Posted December 17, 2010 Share Posted December 17, 2010 Or you can simply format it in the query string, instead of using some convoluted php code to format it. Assuming you're using MySQL: SELECT DATE_FORMAT(`timestamp_field`, '%M, %Y) AS stamp FROM `table` . . . etc. Link to comment https://forums.phpfreaks.com/topic/221968-timestamp-from-db/#findComment-1148625 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.