You can use the base modules: POSIXandTime::Local
1. Mark the date (sec, min, hour, day, month, year)
2. convert your date in seconds (era)
3. Use the strftime function to get a week from the current date
use strict;
use Time::Local;
use POSIX qw(strftime);
my $date = '08/15/2012';
my ($month, $day, $year) = split '/', $date;
my $epoch = timelocal( 0, 0, 0, $day, $month - 1, $year - 1900 );
my $week = strftime( "%U", localtime( $epoch ) );
printf "Date: %s № Week: %s\n", $date, $week;
OUTPUT
Date: 08/15/2012 № Week: 33
source
share