How can I print dates in multiple locales in Perl?

Suppose you need to print the same date formatted appropriate for multiple locales. Perl’s DateTime module can be mixed in with DateTime::Locale to make that easy. Not, necessarily fast or lightweight, mind you, but easy.

The following Perl script provides a demonstration:

#!/usr/bin/env perl

use strict; use warnings;

use DateTime;
use DateTime::Locale;

binmode STDOUT, ':utf8';

my $dt = DateTime->today;
print_date( $dt );

for my $locale ( qw(ar da de en_GB es fr ru tr) ) {
    $dt->set_locale( $locale );
    print_date( $dt );

sub print_date {
    my ($dt) = @_;
    my $locale = $dt->locale;

        "In %s: %s\n", $locale->name,

And, here’s the output:

In English United States: Friday, December 16, 2011
In Arabic: الجمعة، 16 ديسمبر، 2011
In Danish: fredag den 16. december 2011
In German: Freitag, 16. Dezember 2011
In English United Kingdom: Friday, 16 December 2011
In Spanish: viernes 16 de diciembre de 2011
In French: vendredi 16 décembre 2011
In Russian: пятница, 16 декабря 2011 г.
In Turkish: 16 Aralık 2011 Cuma

Of course, if you don’t have the required fonts installed, certain characters may be displayed as unknown.