in reply to I want to know the current week number of the current month
I might be missing something, but I don't see a function in Date::Calc. Here's a DateTime solution:
use DateTime; my $dt = DateTime->now; my $date = $dt->strftime("%b %Y"); my $week = $dt->week_of_month(); print "It is Week: $week As of $date\n"; __END__ It is Week: 2 As of Oct 2017
However, note that the week number returned here can be zero - from the DateTime docs on week_of_month:
The first week of the month is the first week that contains a Thursday. This is based on the ICU definition of week of month, and correlates to the ISO8601 week of year definition. A day in the week before the week with the first Thursday will be week 0.
So you need to have a clear definition of what the Nth week means for you. (Update: LanX made the same point here.)
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: I want to know the current week number of the current month
by Muskovitz (Scribe) on Oct 12, 2017 at 13:09 UTC | |
by haukex (Archbishop) on Oct 13, 2017 at 09:22 UTC | |
by thanos1983 (Parson) on Oct 12, 2017 at 16:15 UTC |