note 50187 deleted from function.date by tularis

From: Date: Mon, 21 Feb 2005 14:42:42 +0000
Subject: note 50187 deleted from function.date by tularis
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-85309@lists.php.net to get a copy of this message
Note Submitter: vasu Reason: spam ---- Hello, I am having some problem with the date functions. For your information i am using PHP Version 4.2.3 which is compiled on a HP UX. I want to write a code which convers the string data 'YYWW' into 'YYMM' format. ex: '0430' -> '0407' since 30th week comes in 07 month it got translated into '0407'. I had posted about this problem on other forums but couldnt get much help there. The code which i got from other forum is: <?php $yearweek='0414'; $year=substr($yearweek,0,2); $week=substr($yearweek,2); $unixtime=mktime(0,0,0,1,(($week-1)*7),$year); echo date('ym',strtotime('last monday',$unixtime)); ?> The above code works good for 2004 year, but again when i change the value of $yearweek to '0510' i get the return value as '0502' where as it should have been '0503'. If the remove the '-1' in line 5 then for 2005 and rest years it works but for 2004 it doesnt. I thought this problem was because of the 2004 being leap year but i was wrong. I tried to make condition which checks for the year being leap year or not. But this too didnt helped me. I dont know how i can solve this problem and will be very glad if anyone can help me in this matter. Thanks. P.s: also, i am using PHP Version 4.2.3 running on HP UX

« previous php.notes (#85309) next »