Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

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;

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.


Comment on Re: Get day of week from current date
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (8)
As of 2014-09-23 20:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (241 votes), past polls