| 1 | $formats = array(
|
|---|
| 2 | // day
|
|---|
| 3 | 'day' => '\d:d | \D:D | \j:j | \l:l | \N:N | \S:S | \w:w | \z:z',
|
|---|
| 4 | // week
|
|---|
| 5 | 'week' => '\W:W',
|
|---|
| 6 | // month
|
|---|
| 7 | 'month' => '\F:F | \m:m | \M:M | \n:n | \t:t',
|
|---|
| 8 | // year
|
|---|
| 9 | 'year' => '\L:L | \o:o | \Y:Y | \y:y',
|
|---|
| 10 | // time
|
|---|
| 11 | 'time' => '\a:a | \A:A | \B:B | \g:g | \G:G | \h:h | \H:H | \i:i | \s:s | \u:u',
|
|---|
| 12 | // timezone
|
|---|
| 13 | 'timezone' => '\e:e | \I:I | \O:O | \P:P | \T:T | \Z:Z',
|
|---|
| 14 | // full date/time
|
|---|
| 15 | 'full_date_time' => '\c:c | \r:r | \U:U',
|
|---|
| 16 | // escape test
|
|---|
| 17 | 'escape' => 'F | \F | \\F | \\\F | \\\\F | \\\\\F | \\\\\\F'
|
|---|
| 18 | );
|
|---|
| 19 |
|
|---|
| 20 | $timestamps = array(
|
|---|
| 21 | 'now local' => current_time('timestamp'),
|
|---|
| 22 | 'now unix (GMT)' => time(),
|
|---|
| 23 | );
|
|---|
| 24 |
|
|---|
| 25 | $outputtemplate = ' with %s: %s<br/>';
|
|---|
| 26 |
|
|---|
| 27 | foreach ( $timestamps as $timestampkey => $timestamp ) {
|
|---|
| 28 | echo('<br/>');
|
|---|
| 29 | echo(sprintf('------ format timestamp %s (%s) ------</br>',
|
|---|
| 30 | $timestamp,
|
|---|
| 31 | $timestampkey
|
|---|
| 32 | ));
|
|---|
| 33 | foreach ( $formats as $formatkey => $format ) {
|
|---|
| 34 | echo(sprintf('format %s: %s</br>',
|
|---|
| 35 | $formatkey,
|
|---|
| 36 | $format
|
|---|
| 37 | ));
|
|---|
| 38 | echo(sprintf($outputtemplate,
|
|---|
| 39 | 'date_i18n()',
|
|---|
| 40 | date_i18n($format, $timestamp, false)
|
|---|
| 41 | ));
|
|---|
| 42 | echo(sprintf($outputtemplate,
|
|---|
| 43 | 'date()',
|
|---|
| 44 | date($format, $timestamp)
|
|---|
| 45 | ));
|
|---|
| 46 | echo(sprintf($outputtemplate,
|
|---|
| 47 | 'date_i18n(gmt)',
|
|---|
| 48 | date_i18n($format, $timestamp, true)
|
|---|
| 49 | ));
|
|---|
| 50 | }
|
|---|
| 51 | }
|
|---|