Link to home
Start Free TrialLog in
Avatar of Bob-Villa
Bob-Villa

asked on

PERL - How to get 1st, 2nd, 3rd etc... Monday, Tuesday, Wednesda, etc ... date in a month

I need to find specific dates. I will always have the Month, Year and Marker.

i.e.
September, 2008.
I need to know the 'date' of the (for example) 1st Monday or 2nd Friday or whatever. Date can be in unixtime,localtime,mysql or some format that I can manipulate. Looking for pure perl or lightweight module.
Avatar of Suhas .
Suhas .
Flag of United States of America image

for that using module Date::Simple
my $date = ymd($year, $month, $day); # for ex sep 2008 give input year = 2008 month = 9 day = 1

then,
print "Today is ";
    print(('Sun','Mon','Tues','Wednes','Thurs','Fri','Satur')
          [$date->day_of_week]);
    print "day.\n"; # you will get the 1st day of week, ex. tuesday

after that its easy for you to find the date of the 1st mon or 3rd mon etc....
little tricky... but you have to write the loops accordingly...

Hope this helps...
ASKER CERTIFIED SOLUTION
Avatar of FishMonger
FishMonger
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial