week-number.net

Programming Languages

Week number in Perl

Getting the week number for a date in Perl can be easily achieved using the POSIX module. The strftime takes a format string and a unix timestamp as arguments.

Example

Get the current week number and print it.


use strict;
use Time::Local;
use POSIX qw(strftime);
my $weekNumber = POSIX::strftime("%V", gmtime time);
print "Week number:$weekNumber";

Output:

Week number:30
comments powered by Disqus