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.


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";


Week number:38
comments powered by Disqus