note 80092 added to function.date

From: Date: Fri, 28 Dec 2007 18:38:03 +0000
Subject: note 80092 added to function.date
Groups: php.notes 
Request: Send a blank email to php-notes+get-134081@lists.php.net to get a copy of this message
I wanted to get the number of weeks for particular year. Example with date(): <?php $weeks_in_year = date("W", strtotime("12/31/2007")); ?> It works for years smaller than current year, but returns '01' when year was the same or bigger as current year. Not sure if I missed something or maybe misused this function but I couldn't get it to work even with different date representations. So the workaround was using different function. Example with strftime(): <?php $weeks_in_year = strftime("%W",strtotime("12/31/2007")); ?> Now it works as a charm. PHP v.4.4.7 ---- Server IP: 213.250.2.28 Probable Submitter: 89.212.41.5 ---- Manual Page -- http://www.php.net/manual/en/function.date.php Edit -- https://master.php.net/note/edit/80092 Del: integrated -- https://master.php.net/note/delete/80092/integrated Del: useless -- https://master.php.net/note/delete/80092/useless Del: bad code -- https://master.php.net/note/delete/80092/bad+code Del: spam -- https://master.php.net/note/delete/80092/spam Del: non-english -- https://master.php.net/note/delete/80092/non-english Del: in docs -- https://master.php.net/note/delete/80092/in+docs Del: other reasons-- https://master.php.net/note/delete/80092 Reject -- https://master.php.net/note/reject/80092 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#134081) next »