You are here

function moment_get_date_format_replacements in Moment.js 7.2

Same name and namespace in other branches
  1. 8.2 moment.module \moment_get_date_format_replacements()

The format replacement patterns for the Moment.js library.

Return value

array Key is the PHP date format character, the value is the corresponding Moment.js format string.

See also

http://php.net/date

http://momentjs.com/docs/#/displaying/format

1 call to moment_get_date_format_replacements()
moment_date_format_to_moment_date_format in ./moment.module
Convert a date format to Moment.js compatible date format.

File

./moment.module, line 275
Moment.js integration.

Code

function moment_get_date_format_replacements() {

  // PHP => Moment.js.
  // PHP does not support the following formats:
  // @todo Complete this list.
  // Seconds              0 1 ... 58 59.
  // '?' => 's'.
  // Day of Week        Su Mo ... Fr Sa.
  // '?' => 'dd'.
  return [
    // Hour             01 02 ... 11 12.
    'h' => 'hh',
    // Hour             00 01 ... 22 23.
    'H' => 'HH',
    // Hour              1  2 ... 11 12.
    'g' => 'h',
    // Hour              0  1 ... 22 23.
    'G' => 'H',
    // Minute           00 01 ... 58 59.
    'i' => 'mm',
    // Seconds.         00 01 ... 58 59.
    's' => 'ss',
    // Year         1970 1971 ... 2029 2030.
    'Y' => 'YYYY',
    // Year           70   71 ...   29   30.
    'y' => 'YY',
    // Month             1  2 ... 11 12.
    'n' => 'M',
    // Month            01 02 ... 11 12.
    'm' => 'MM',
    // Month          Jan Feb ... Nov Dec.
    'M' => 'MMM',
    // Month January February ... November December.
    'F' => 'MMMM',
    // Day of Year    001 002 ... 364 365.
    'z' => 'DDDD',
    // Day of Month      1  2 ... 30 31.
    'j' => 'D',
    // Day of Month     01 02 ... 30 31.
    'd' => 'DD',
    // Day of Month   1st 2nd ... 30th 31st.
    'jS' => 'Do',
    // Day of Week        0 1 ... 5 6.
    'w' => 'd',
    // Day of Week (ISO)  1 2 ... 6 7.
    'N' => 'E',
    // Day of Week    Sun Mon ... Fri Sat.
    'D' => 'ddd',
    // Day of W Sunday Monday ... Friday Saturday.
    'l' => 'dddd',
    // Week of Year       1 2 ... 52 53.
    'W' => 'w',
    // Timezone -07:00 -06:00 ... +06:00 +07:00.
    'P' => 'Z',
    // Timezone   -0700 -0600 ... +0600 +0700.
    'O' => 'ZZ',
    // Shortcut to: "Y-m-d\TH:i:sP".
    // Example:     "2004-02-12T15:19:21+00:00".
    'c' => 'YYYY-MM-DDTHH:mm:ssZ',
    // Shortcut to: "D, d M Y H:i:s O".
    // Example:     "Thu, 21 Dec 2000 16:01:07 +0200".
    'r' => 'ddd, DD MMM YYYY HH:mm:ss ZZ',
    // Unix Timestamp.
    'U' => 'X',
  ];
}