J
Justin C
I need to output the date as six digits DDMMYY, with leading zeros where
necessary, and only the last two digits of the year.
Looking through the documentation for DateTime I find I can only find
four digit year formats. I know there's always more than one way to do
it, but I can't see an easy way other than:
=== begin ===
#!/usr/bin/perl
use strict;
use warnings;
use POSIX;
use DateTime;
my $date = DateTime->now();
my $year = substr($date->year, 2, 2);
my $month = substr($date->dmy, 3, 2);
my $day = substr($date->dmy, 0, 2);
my $formattedDate = $day . $month . $year;
print "$formattedDate\n";
=== end ===
Is there a 'cleaner' way, just using the DateTime module?
Justin.
necessary, and only the last two digits of the year.
Looking through the documentation for DateTime I find I can only find
four digit year formats. I know there's always more than one way to do
it, but I can't see an easy way other than:
=== begin ===
#!/usr/bin/perl
use strict;
use warnings;
use POSIX;
use DateTime;
my $date = DateTime->now();
my $year = substr($date->year, 2, 2);
my $month = substr($date->dmy, 3, 2);
my $day = substr($date->dmy, 0, 2);
my $formattedDate = $day . $month . $year;
print "$formattedDate\n";
=== end ===
Is there a 'cleaner' way, just using the DateTime module?
Justin.