MySQL date_format

Cut and Paste date_format strings for MySQL

select date_format(date, '%a %D %b %Y') as formatted_date from table_name;

Where date is the name of your date field, and formatted_date is a variable name which you can use to retrieve the value.

Example Date: 1st April 2005
Replace date with the name of your date field...
date_format String Example
2005-04-01
1/4/2005 UK
4/1/2005 US
01/04/2005 UK
04/01/2005 US
1/4/2005 12:30 UK
4/1/2005 12:30 US
01/04/2005 12:30 UK
04/01/2005 12:30 US
1/4/2005 12:30:10 UK
4/1/2005 12:30:10 US
01/04/2005 12:30:10 UK
04/01/2005 12:30:10 US
Fri 1st Apr 2005
Fri 1st Apr 2005 12:30
Fri 1st Apr 2005 12:30:10
Fri Apr 1 2005
Fri Apr 1 2005 12:30
Fri Apr 1 2005 12:30:10
Friday 1st April 2005
Friday 1st April 2005 12:30
Friday 1st April 2005 12:30:10
12:30 PM Apr 1, 2005
April 1, 2005
Below: RFC2822 e.g. for iTunes Podcast
Thanks to Andy Moyle for providing!
Fri, 01 Apr 2005 12:30:10

If I've missed a common date format, get in touch and I'll add it.

© Dan Winchester 2005