in reply to Get day of week from current date
Use DateTime.
#!/usr/bin/env perl use 5.012; use warnings; use DateTime; my $dt = DateTime->new(year => 2002, month => 2, day => 21); say "I'm pretty sure it was a " . $dt->day_name; say "Today is " . DateTime->now()->day_name;
Output:
I'm pretty sure it was a Thursday Today is Monday
If that output is not to your liking, look at the many methods in DateTime for more options such as numeric or abbreviated weekdays.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Get day of week from current date
by Anonymous Monk on Sep 11, 2015 at 07:05 UTC |
In Section
Seekers of Perl Wisdom