Format date

Let's look at the functions for formatting dates programmatically in Drupal 6 and 7. Basically, you can use the core format_date function or you can leverage the date module and use date_format_date. In theory, the latter is better because it uses a date object instead of a unix timestamp (and you don't have to worry about 2038 ;). Here's a snippet using both functions in D 6/7.