a simple javascript date formatter
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


This is a Javascript implementation of the popular date formatting utility strftime.


There are three different ways to use this:

  1. Using the Date.format function:

    Date.format(new Date("10 Jan 2011"), "%B %d, %Y"); // "January 10, 2011"

  2. Using the Date.prototype.format function on a date:

    new Date("16 Apr 2011").format("%B %d, %Y"); // "April 16, 2011"

  3. Using the C-style strftime function:

    strftime("%B %d, %Y", new Date("7 Dec 1999")); // "December 7, 1999"

If you use this version, the second parameter is optional and defaults to the current date.


  • %A: Full weekday name ("Sunday")

  • %a: Abbreviated weekday name ("Sun")

  • %B: Full month name ("January")

  • %b: Abbreviated month name ("Jan")

  • %C: Century, zero-padded (21)

  • %D: Day of the month (1-31)

  • %d: Two-digit day of the month, zero-padded (01-31)

  • %e: Two-character day of the month, space-padded (" 1"-"31")

  • %G: Four-digit version of the year, by ISO-8601:1988 standards (see %V)

  • %g: Two-digit version of %G

  • %H: Two-digit hour in 24-hour format (00-23)

  • %I: Two-digit hour in 12-hour format (01-12)

  • %i: Hours in 24-hour format (0-23).

  • %j: Three-digit day of the year (001-366).

  • %l: Hours in 12-hour format (1-12)

  • %M: Two-digit minutes (00-59)

  • %m: Current month, zero-padded

  • %P: Upper case "AM" or "PM" for the given time

  • %p: Lower case "am" or "pm" for the given time

  • %S: Two-digit representation of the second (00-59)

  • %U: Week number in the given year, with the first Sunday starting the first week

  • %u: ISO-8601 day of the week (1 (Monday) - 7 (Sunday))

  • %V: ISO-8601:1988 week number of the year, starting with the first week of the year with at least 4 weekdays, using Monday as the first day of the week (01-53)

  • %W: Week number of the current year, where the first Monday is week 1.

  • %w: Day of the week (0 (Sunday) - 6 (Saturday))

  • %X: Locale time string (17:46:21)

  • %x: Locale date string (Thursday, February 12, 2009)

  • %Y: Four-digit year (2008)

  • %y: Two-digit year (08)

  • %z: Time zone offset (-0800)

  • %Z: Time zone name (PST)

  • %%: A percent (%) sign