Help - Search mySQL post on a date field

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Rippie
Forum Commoner
Posts: 76
Joined: Sun Jan 10, 2010 11:32 am
Location: Nottingham

Help - Search mySQL post on a date field

Post by Rippie »

Hi all,

When adding in new posts into a mysql table i would like to later on be able to search on posts that was added in the last year or month. Can someone advise the best way to store the dates in mysql? field type and date format? If i use date field instead of varchar the dates are in US format and i want them in UK format. also i am not sure if we can search on them if they are in the format of 14/05/2010.

Hope someone can advise me on best practice.
mikosiko
Forum Regular
Posts: 757
Joined: Wed Jan 13, 2010 7:22 pm

Re: Help - Search mySQL post on a date field

Post by mikosiko »

I will use DATE as the field type if the time is not relevant, DATETIME otherwise, and use date_format() to manipulate the date format in the way I want.
Post Reply