dunff2k Posted December 29, 2006 Share Posted December 29, 2006 Hello I'm a newbie to Dates in PHPI'm writing an application that queries a database for the objects added within the last 4 months and displays them ordered by month.Would it be more beneficial to store the dateAdded field as a DATE in the mysql database and use the mysql date functions or as a VARCHAR and use the PHP functionalityAny advice would be appreciatedPaul Link to comment https://forums.phpfreaks.com/topic/32209-php-dates/ Share on other sites More sharing options...
ted_chou12 Posted December 29, 2006 Share Posted December 29, 2006 I suggest you use DATE instead of VARCHAR. because it is designed for date format storage. :DTed Link to comment https://forums.phpfreaks.com/topic/32209-php-dates/#findComment-149498 Share on other sites More sharing options...
Caesar Posted December 29, 2006 Share Posted December 29, 2006 You can also make it an integer field and store the dates as timestamps. Makes for really really easy sorting and retrieval. So long as you don't store formatted dates, you'll be golden. Link to comment https://forums.phpfreaks.com/topic/32209-php-dates/#findComment-149504 Share on other sites More sharing options...
c_shelswell Posted December 29, 2006 Share Posted December 29, 2006 i'd go for timestamps it's easier to compare against another date ie earlier or later. if you use a 12-12-2006 kind of date i've found it a bit of a pain to compare them without turning them into timestamp Link to comment https://forums.phpfreaks.com/topic/32209-php-dates/#findComment-149508 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.