This week is ...
Week 05
Week 05 is from Monday January 30, 2012 until (and including) Sunday February 5, 2012.
Week number according to the ISO-8601 standard, weeks starting on Monday. The first week of the year is the week that contains that year's first Thursday. The highest week number in a year is either 52 or 53.
Lists of week numbers by year : 2011 - 2012 - 2013 ...
Programming routines
PERL
my $weekNumber = POSIX::strftime("%V", gmtime time);
Replace time with other epoch/UNIX timestamps for other week numbers.
PHP
$weekNumber = date("W");
or date("W", epoch) for other week numbers. Remember to use capital 'W' not 'w'.
Java
Use WEEK_OF_YEAR in the Calendar class.
More info on Stack Overflow
MySQL
SELECT WEEKOFYEAR(NOW())
Replace now() with other dates eg. SELECT WEEKOFYEAR('2008-02-20');
(You can also use the WEEK function with mode=3 select week(now(),3))
MS SQL
SELECT DATEPART( wk, GETDATE() )
Oracle
SELECT to_char(sysdate, 'WW') FROM DUAL
iPhone/Mac
[NSString stringWithFormat:@"Week %d", [calendar ordinalityOfUnit:NSWeekCalendarUnit inUnit:NSYearCalendarUnit forDate:date]];
Python
import time
week_number_as_string = time.strftime("%W")
week_number = int(week_number_as_string)
Ruby
week_number = Time.now.strftime("%U")
Replace Time.now with Time.local(year,month,day) for other dates.
Formats:
%U - Week number of the year, starting with the first Sunday as the first day of the first week (00..53)
%V - Week number of year according to ISO 8601 (01..53)
%W - Week number of the year, starting with the first Monday as the first day of the first week (00..53)
Microsoft Excel
=WEEKNUM(A1)-1Week numbers can vary based on your locality settings (not ISO-8601!). See discussion below.
Unix/Linux
date +%W
PowerShell
Get-Date -UFormat %V
Thanks to everyone who sent me corrections and updates!
Also see: Current day number
Comments and questions
blog comments powered by DisqusPages
HomeTools
Epoch converter
Batch converter
Epoch clock
Epoch list
Time zone converter
Programming
Routines by language
Epoch in PERL
Epoch in C
Epoch in MySQL
Epoch in VBScript/ASP/JavaScript/PHP
Date and Time
Calculate difference between two dates
Week numbers
Weeks by year
Day numbers
More
Comments & questions
Epoch Converter for Mobiles
Este sitio en Español
Related cookbooks
Unicode Tools
Character Set Tools
Follow our Facebook Page: