Faqts : Business : Programming : Shopping For You : PHP : Function Libraries : Date and Time

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

11 of 12 people (92%) answered Yes
Recently 8 of 9 people (89%) answered Yes

Entry

How can I get the current day of the year as a number (eg: 358)?

Aug 15th, 1999 09:00
Nathan Wallace, se@lakenet.no


look at the function date():

    http://www.php.net/manual/function.date.php3

z - day of the year; i.e. "0" to "365", so:

    $day_number=date("z");

This returns January 1 as being 0.  If you want the day numbers to be
the usual 1-365 then you should use:

    $day_number=date("z")+1;