View Full Version : php : day of the year
razor
June 2nd, 2001, 14:10
does any one know how i would convert july 8th into the day of the year?
Canuckkev
June 2nd, 2001, 18:09
Like you want to find the number of the day in the year, like out of 365? Some simple math functions could do it. There might be some built in php thing too, but I don't know any php. Just don't forget about leap years when coding it.
lucifer
June 3rd, 2001, 08:18
getdate
(PHP3 , PHP4 )
getdate -- Get date/time information
Description
array getdate (int timestamp)
Returns an associative array containing the date information of the timestamp as the following array elements:
"seconds" - seconds
"minutes" - minutes
"hours" - hours
"mday" - day of the month
"wday" - day of the week, numeric
"mon" - month, numeric
"year" - year, numeric
"yday" - day of the year, numeric; i.e. "299"
"weekday" - day of the week, textual, full; i.e. "Friday"
"month" - month, textual, full; i.e. "January"
razor
June 3rd, 2001, 12:05
here is the snippet:
$timestamp = mktime (0, 0, 0, $month, $day, $year);
$time = getdate($timestamp);
$yday = $time['yday'];
$yday = $yday + 1;
echo $yday;
Powered by vBulletin® Version 4.1.7 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.