Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Re: Get day of week from current date

by rjt (Deacon)
on Jul 08, 2013 at 11:34 UTC ( #1043090=note: print w/ replies, xml ) Need Help??

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;


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.

Comment on Re: Get day of week from current date
Select or Download Code
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
    Date:Calc is easy and more versatile than Date::Simple and DateTime. use Date::Calc qw(:all); print Day_of_Week($year,$month,$day);

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1043090]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2015-11-29 20:34 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (753 votes), past polls