DateTime lets you specify a formatter, which is used whenever you print or stringify a DateTime object:
use strict; use warnings; use DateTime; use DateTime::Format::Strptime; my $start_of_week = DateTime->today() ->truncate( to => 'week' ); $start_of_week->set_formatter( DateTime::Format::Strptime->new(pattern + => "%d-%m-%y") ); for ( 0..6 ) { my $teden = $start_of_week->clone()->add( days => $_ ); print "$teden\n"; }
This is useful when you print in many places of your code and want the same format. Remark: installing DateTime::Format::Strptime unleashed a cascade of dependencies on my Perl install...
In reply to Re: Two digit year with DateTime?
by hdb
in thread Two digit year with DateTime?
by mitabrev
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |