Skip to content

Instantly share code, notes, and snippets.

@blar
Last active December 24, 2015 11:29
Show Gist options
  • Select an option

  • Save blar/6791278 to your computer and use it in GitHub Desktop.

Select an option

Save blar/6791278 to your computer and use it in GitHub Desktop.
DateFormatter
<?php
date_default_timezone_set('Europe/Berlin');
Locale::setDefault('de_DE');
$formatter = new IntlDateFormatter(NULL, IntlDateFormatter::FULL, IntlDateFormatter::FULL);
var_dump($formatter->format(new DateTime()));
$formatter = new IntlDateFormatter(NULL, IntlDateFormatter::FULL, IntlDateFormatter::LONG);
var_dump($formatter->format(new DateTime()));
$formatter = new IntlDateFormatter(NULL, IntlDateFormatter::FULL, IntlDateFormatter::SHORT);
var_dump($formatter->format(new DateTime()));
$formatter = new IntlDateFormatter(NULL, IntlDateFormatter::LONG, IntlDateFormatter::LONG);
var_dump($formatter->format(new DateTime()));
$formatter = new IntlDateFormatter(NULL, IntlDateFormatter::MEDIUM, IntlDateFormatter::SHORT);
var_dump($formatter->format(new DateTime()));
$formatter = new IntlDateFormatter(NULL, IntlDateFormatter::SHORT, IntlDateFormatter::FULL);
var_dump($formatter->format(new DateTime()));
Locale::setDefault('en_US');
$formatter = new IntlDateFormatter(NULL, IntlDateFormatter::FULL, IntlDateFormatter::FULL);
var_dump($formatter->format(new DateTime()));
$formatter = new IntlDateFormatter(NULL, IntlDateFormatter::FULL, IntlDateFormatter::LONG);
var_dump($formatter->format(new DateTime()));
$formatter = new IntlDateFormatter(NULL, IntlDateFormatter::FULL, IntlDateFormatter::SHORT);
var_dump($formatter->format(new DateTime()));
$formatter = new IntlDateFormatter(NULL, IntlDateFormatter::LONG, IntlDateFormatter::LONG);
var_dump($formatter->format(new DateTime()));
$formatter = new IntlDateFormatter(NULL, IntlDateFormatter::MEDIUM, IntlDateFormatter::SHORT);
var_dump($formatter->format(new DateTime()));
$formatter = new IntlDateFormatter(NULL, IntlDateFormatter::SHORT, IntlDateFormatter::FULL);
var_dump($formatter->format(new DateTime()));
string(64) "Mittwoch, 2. Oktober 2013 11:35:20 Mitteleuropäische Sommerzeit"
string(39) "Mittwoch, 2. Oktober 2013 11:35:20 MESZ"
string(31) "Mittwoch, 2. Oktober 2013 11:35"
string(29) "2. Oktober 2013 11:35:20 MESZ"
string(16) "02.10.2013 11:35"
string(47) "02.10.13 11:35:20 Mitteleuropäische Sommerzeit"
string(70) "Wednesday, October 2, 2013 at 11:35:20 AM Central European Summer Time"
string(47) "Wednesday, October 2, 2013 at 11:35:20 AM GMT+2"
string(38) "Wednesday, October 2, 2013 at 11:35 AM"
string(36) "October 2, 2013 at 11:35:20 AM GMT+2"
string(21) "Oct 2, 2013, 11:35 AM"
string(49) "10/2/13, 11:35:20 AM Central European Summer Time"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment