Today Wednesday June 19, 2013 is ...
Day 170
Day of year is a number between 1 and 365 (January 1 is day 1).
After today there are 195 days remaining in this year.
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).
Lists of day numbers by year : 2012 - 2013 - 2014 - 2015 ...
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)
Visual Basic (VB.NET)
Dim dayOfYear As Integer = DateTime.Now.DayOfYear
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())#
LibreOffice Calc:
=ROUNDDOWN(DAYS(NOW(),DATE(YEAR(NOW()),1,1))) + 1
Objective C
int currentDay; dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setDateFormat:@"D"]; date = [NSDate date]; currentDay = [[dateFormatter stringFromDate:date] intValue];
C++
Read the comment below by Mmars.Java
import java.util.Calendar;
import java.util.Date;
import java.util.TimeZone;
public class DayOfYear
{
public static void main(String args[])
{
Calendar localCalendar = Calendar.getInstance(TimeZone.getDefault());
int CurrentDayOfYear = localCalendar.get(Calendar.DAY_OF_YEAR);
System.out.println("Day of Year: " + CurrentDayOfYear);
Calendar gmtCalendar = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
}
}
Powershell
$DayOfYear = (Get-Date).DayofYear Write-Host $DayOfYear
LiveCode
on mouseUp put "January 1," && the last word of the long date into firstDayofYear --append current year convert firstDayofYear to seconds -- from Jan 1, 1970 to first day of this year put the long date into currentDay convert currentDay to seconds -- from Jan 1, 1970 GMT to today put currentDay - firstDayofYear into totalSeconds answer the round of (totalSeconds / (60*60*24)) + 1 --display total days in dialog box end mouseUpOr:
on mouseUp answer DayOfYear() end mouseUp function DayOfYear put the short date into currentDate convert currentDate to dateItems --list of date elements separated by commas put item 1 of currentDate into year put item 2 of currentDate into month put item 3 of currentDate into day put floor (275 * month / 9) into N1 put floor ( (month + 9) / 12) into N2 put (1 + floor ( (year - 4 * floor (year / 4) + 2) / 3) ) into N3 put N1 - (N2 * N3) + day - 30 into N return N end DayOfYear function floor pNumber -- LiveCode has no built-in floor() function put Round (pNumber) into theInteger if theInteger > pNumber then put theInteger - 1 into theInteger end if return theInteger end floor
Thanks to all developers who contributed to this page!! (read comments below)
Also see: Current week number
Comments and questions
blog comments powered by DisqusPages
Home
Tools
Epoch converter
Batch converter
Epoch clock
Epoch list
Time zone converter
LDAP converter
Unix hex timestamp
Mac timestamp
Bin/Oct/Hex converter
Programming
Routines by language
Epoch in C
Epoch in MySQL
Epoch in PERL
Epoch in PHP
Epoch in VBScript/ASP/JavaScript
Tools
Epoch converter
Batch converter
Epoch clock
Epoch list
Time zone converter
LDAP converter
Unix hex timestamp
Mac timestamp
Bin/Oct/Hex converter
Programming
Routines by language
Epoch in C
Epoch in MySQL
Epoch in PERL
Epoch in PHP
Epoch in VBScript/ASP/JavaScript
Date and Time
Calculate difference
between two dates
Week numbers
Weeks by year
Day numbers
Days by year
More
Comments & questions
Este sitio en Español
Related cookbooks
Unicode Tools
Character Set Tools
Follow us
Calculate difference
between two dates
Week numbers
Weeks by year
Day numbers
Days by year
More
Comments & questions
Este sitio en Español
Related cookbooks
Unicode Tools
Character Set Tools
Follow us
