use Date::Simple ('date', 'today');
# Difference in days between two dates:
$diff = date('2001-08-27') - date('1977-10-05');
# Offset $n days from now:
$date = today() + $n;
print "$date\n"; # uses ISO 8601 format (YYYY-MM-DD)
use Date::Simple ();
my $date = Date::Simple->new('1972-01-17');
my $year = $date->year;
my $month = $date->month;
my $day = $date->day;
use Date::Simple (':all');
my $date2 = ymd($year, $month, $day);
my $date3 = d8('19871218');
my $today = today();
my $tomorrow = $today + 1;
if ($tomorrow->year != $today->year) {
print "Today is New Year's Eve!\n";
}
if ($today > $tomorrow) {
die "warp in space-time continuum";
}
print "Today is ";
print(('Sun','Mon','Tues','Wednes','Thurs','Fri','Satur')
[$today->day_of_week]);
print "day.\n";
# you can also do this:
($date cmp "2001-07-01")
# and this
($date <=> [2001, 7, 1])
#############
format
############
my $change_date = $date->format("%d %b %y");
my $iso_date1 = $date->format("%Y-%m-%d");
my $iso_date2 = $date->format;
댓글 없음:
댓글 쓰기