RE: [PHP] take date and convert to day of year

From: Date: Tue, 13 Nov 2001 22:35:01 +0000
Subject: RE: [PHP] take date and convert to day of year
Groups: php.general 
Request: Send a blank email to php-general+get-74496@lists.php.net to get a copy of this message
looking at the manual, getdate() is meant to be passed a unix time stamp, so, you'll need to use strtotime() first thus: $utime = strtotime("30-Nov-1971"); $dob = getdate($utime); $dobnum = $dob['yday']; print $dobnum; Notice I changed the format of the date, when I tried using the original format, strtotime() complained, saying it couldn't convert it. Martin T -----Original Message----- From: sundogcurt [mailto:sundogcurt@netscape.net] Sent: Wednesday, November 14, 2001 7:57 AM To: GENERAL PHP LIST Subject: [PHP] take date and convert to day of year Hi guys, I know that you can take todays date and display it as the numeric day of the year, 1 - 365 / 0 - 364 etc. But can you take a date such as (November-30-1971) and convert that to the numeric day of the year? I have been trying to do this but have had no joy, I don't think my code is even close. $dob = getdate("Nov-30-1971"); $dobnum = $dob['yday']; print $dobnum; $dob 'should' be an array and 'yday' should be the numeric value for the day of the year, right?!? This is what I am trying, and how I understand it, using 'yday' should give you basically the same output as date ("z"); What I would like is the ability to convert any date to the days numeric value. Any help would be GREATLY appreciated. (C: -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#74496) next »