Skip to content

Instantly share code, notes, and snippets.

@lsolesen
Created May 24, 2010 08:37
Show Gist options
  • Save lsolesen/411656 to your computer and use it in GitHub Desktop.
Save lsolesen/411656 to your computer and use it in GitHub Desktop.
Using intl pecl extension
// using the intl pecl extension
$datefmt = new IntlDateFormatter("da-DK", IntlDateFormatter::SHORT, IntlDateFormatter::SHORT, date_default_timezone_get());
$danish = '2010-10-10 10:10:10';
$formatted = $datefmt->format(strtotime($danish)); // 10/10/10 10.10
echo $parsed = $datefmt->parse($formatted); // 1286698200
$fmt = new NumberFormatter( 'da_DK', NumberFormatter::DECIMAL );
$num = "1234.567,891";
$parsed_number = $fmt->parse($num); // 1234567.891
$fmt->format($parsed_number); // 1.234.567,891
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment