The DateTime module with its DateTime::Format::Strptime companion makes it easy to print out your date string in different locales:
en_US: Monday, February 13, 2006 17:57 de_DE: Montag, Februar 13, 2006 17:57 fr_FR: lundi, février 13, 2006 17:57 es_ES: lunes, febrero 13, 2006 17:57
which is easily accomplished with this code:
use DateTime; use DateTime::Format::Strptime; my $dt = DateTime->now( time_zone => "America/Los_Angeles", ); for my $locale (qw(en_US de_DE fr_FR es_ES)) { $dt->set_locale($locale); my $format = DateTime::Format::Strptime->new( pattern => "%A, %B %d, %Y %H:%M", ); $dt->set_formatter($format); print "$locale: $dt\n"; }
However, different countries have different formatting rules as well:
en_GB: 13 February 2006 17:49:49 UTC en_US: February 13, 2006 5:49:49 PM UTC de_DE: 13. Februar 2006 17:49:49 UTC fr_FR: 13 février 2006 17:49:49 UTC es_ES: 13 de febrero de 2006 17:49:49 UTC es_MX: 13 de febrero de 2006 5:49:49 PM UTC
The code for this goes like that:

use strict; use DateTime; use DateTime::Format::Strptime; my $dt = DateTime->now(); for my $locale (qw(en_GB en_US de_DE fr_FR es_ES es_MX)) { $dt->set_locale($locale); my $format = DateTime::Format::Strptime->new( pattern => $dt->locale()-> long_datetime_format() ); $dt->set_formatter($format); print "$locale: $dt\n"; }

In reply to Re: Date format by saintmike
in thread Date format by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.