The SitePoint Forums have moved.

You can now find them here.
This forum is now closed to new posts, but you can browse existing content.
You can find out more information about the move and how to open a new account (if necessary) here.
If you get stuck you can get support by emailing forums@sitepoint.com

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

TIMESTAMP[(M)]Description: A timestamp (date/time), in YYYYMMDDHHMMSS format.Range: 19700101000000 to sometime in 2037 on current systems.Storage space: 4 bytes (32 bits)Notes: An INSERT or UPDATE operation on a row containing one or more TIMESTAMP columns will automatically update the first TIMESTAMP column in the row with the current date/time. This lets you use such a column as the 'last modified date/time' for the row. Assigning a value of NULL to the column will have the same effect, thereby providing a means of 'touching' the date/time. You can also assign actual values as you would for any other column.
Allowable values for M are 14, 12, 10, 8, 6, 4, and 2, and correspond to the display formats YYYYMMDDHHMMSS, YYMMDDHHMMSS, YYMMDDHHMM, YYYYMMDD, YYMMDD, YYMM, and YY respectively. Odd values from 1 to 13 will automatically be bumped up to the next even number, while values of 0 or greater than 14 are changed to 14.

For those who are curious, the book version contains the fully revised and updated edition of the article series (I've been working on it for a month!), and two additional chapters that will not be appearing online. As of right now, those chapters will be covering Sessions/Cookies and storing/retrieving binary data in MySQL, but that may still change. To top it off, there will be extremely handy reference appendices documenting MySQL syntax, MySQL functions, MySQL column types, and PHP's MySQL functions.

Price yet to be set, but you can pretty much count on it not being another $65 book you'll never read all the way through. We are also considering offering it as an e-book in PDF format for a smaller price.

MySQL's DATE_FORMAT function does exactly this. Again, from the reference section of the upcoming book (apologies for the poorly formatted table -- I'm in a bit of a hurry):

DATE_FORMAT(date,format)
Takes the date or time value date and returns it formatted according to the formatting string format, which may contain any of the following symbols as placeholders shown in Table 2.

Table 2 – DATE_FORMAT() symbols (example: 2001-01-01 01:00:00)

Code:

Symbol Displays Example
%M Month name January
%W Weekday name Monday
%D Day of the month with English suffix 1st
%Y Year, numeric, 4 digits 2001
%y Year, numeric, 2 digits 01
%X Year for the week where Sunday is the 1st day of the week, 4 digits (use with %V) 2001
%x Like %X, Monday 1st day of the week (%v) 2001
%a Abbreviated weekday name Mon
%d Day of the month 01
%e Day of the month 1
%m Month of the year, numeric 01
%c Month of the year, numeric 1
%b Abbreviated month name Jan
%j Day of the year 001
%H Hour of the day (24-hour format, 00-23) 01
%k Hour of the day (24-hour format, 0-23) 1
%h Hour of the day (12-hour format, 01-12) 01
%I Hour of the day (12-hour format, 01-12) 01
%l Hour of the day (12-hour format, 1-12) 1
%i Minutes 00
%r Time, 12-hour (hh:mm:ss: AM/PM) 01:00:00 AM
%T Time, 24-hour (hh:mm:ss) 01:00:00
%S Seconds 00
%s Seconds 00
%p AM or PM AM
%w Day of the week, numeric (0=Sunday) 1
%U Week (00-53), Sunday 1st day of the week 01
%u Week (00-53), Monday 1st day of the week 01
%V Week (1-53), Sunday 1st day of week (%X) 01
%v Week (1-53), Monday 1st day of week (%x) 01
%% An actual percent sign %