astralaaron Posted February 25, 2012 Share Posted February 25, 2012 I have been storing time with php's time() unix timestamp knowing it can be converted to the format that I want to display on my pages. Also it was easy enough for me to calculate when a posting has been online for over a month or so letting me drop them out of my database when I wanted... But everytime I learn something new from a different website or tutorial they do it differently. For example using the CURRENT_TIMESTAMP shows something like 2012-02-25 05:25:00 I feel weird not knowing if what I am doing is a good or bad method. Plus right now I am trying to think how I would use the normal timestamp that I have been using to pull out archived news by month. for example the links would like this: Archived NewsJanuary 2012December 2011November 2011October 2011etc... Link to comment Share on other sites More sharing options...
birbal Posted February 25, 2012 Share Posted February 25, 2012 http://dev.mysql.com...rrent-timestamp check this . this work something like NOW() means the data type would be date Using timestamp has some advanatges like as it is ineteger it is faster than date type. You dont need to think about timezone and formats. you can easily swap beetween format and timezone using php functions like http://php.net/datehttp://in2.php.net/manual/en/function.date-default-timezone-set.php Link to comment Share on other sites More sharing options...
astralaaron Posted February 25, 2012 Author Share Posted February 25, 2012 Thank you birbal, Lot's of information on that page I will read through it. http://dev.mysql.com...rrent-timestamp check this . Link to comment Share on other sites More sharing options...
astralaaron Posted February 25, 2012 Author Share Posted February 25, 2012 ok great I got something that will work fine off of that page. thanks again. SELECT * FROM `news` WHERE month(`created_at`) = 2 AND year(`created_at`) = 2011 easy enough Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.