jPaq Docs - Date.prototype.format()

Quick Stats

Target Platforms:  PC (JScript) and the web (JavaScript)
Download Count:  687

Summary

Gets a string for this date, formatted according to the given format string.

Parameters

  1. format => String

    The format of the output date string. The format string works in a nearly identical way to the PHP date function which is highlighted here: http://php.net/manual/en/function.date.php. The only difference is the fact that "u" signifies milliseconds instead of microseconds. The following characters are recognized in the format parameter string:

    • d - Day of the month, 2 digits with leading zeros
    • D - A textual representation of a day, three letters
    • j - Day of the month without leading zeros
    • l (lowercase 'L') - A full textual representation of the day of the week
    • N - ISO-8601 numeric representation of the day of the week (starting from 1)
    • S - English ordinal suffix for the day of the month, 2 characters st, nd, rd or th. Works well with j.
    • w - Numeric representation of the day of the week (starting from 0)
    • z - The day of the year (starting from 0)
    • W - ISO-8601 week number of year, weeks starting on Monday
    • F - A full textual representation of a month, such as January or March
    • m - Numeric representation of a month, with leading zeros
    • M - A short textual representation of a month, three letters
    • n - Numeric representation of a month, without leading zeros
    • t - Number of days in the given month
    • L - Whether it's a leap year
    • o - ISO-8601 year number. This has the same value as Y, except that if the ISO week number (W) belongs to the previous or next year, that year is used instead.
    • Y - A full numeric representation of a year, 4 digits
    • y - A two digit representation of a year
    • a - Lowercase Ante meridiem and Post meridiem
    • A - Uppercase Ante meridiem and Post meridiem
    • B - Swatch Internet time
    • g - 12-hour format of an hour without leading zeros
    • G - 24-hour format of an hour without leading zeros
    • h - 12-hour format of an hour with leading zeros
    • H - 24-hour format of an hour with leading zeros
    • i - Minutes with leading zeros
    • s - Seconds, with leading zeros
    • u - Milliseconds

Returns

String
Returns the string for this date, formatted according to the given format string.