Epoch ConverterEpoch Converter

What's the Current Day Number?

Today February 5, 2012 is ...

Day 36

Day of year is a number between 1 and 366 (January 1 is day 1).

Some application use 'ISO day of year' numbers, this is a number between 1 and 371, day 1 of the year is Monday of the first ISO week (where the first Thursday of the new year is in week 1).

Programming routines

PHP

$dayNumber = date("z") + 1; 
You can use an epoch to find other day numbers:
date("z", epoch) + 1
date("z") starts counting from 0 (0 through 365)!

Python

day_of_year = datetime.now().timetuple().tm_yday

PERL

my $dayNumber = POSIX::strftime("%j", gmtime time);
Replace time with other epochs for other days.

MySQL

SELECT DAYOFYEAR(NOW())
Day number between 1 and 366. Replace now() with other dates eg.:
SELECT DAYOFYEAR('2008-02-20');

Microsoft Access

DatePart("y",Date)

JavaScript

Add a 'Day of Year' method to the date object:
'Day of Year Date Method' on About.com

Unix/Linux

date +%j

ColdFusion

#dayofyear(now())# 

Also see: Current week number


Comments and questions

blog comments powered by Disqus