note 112112 added to function.strftime
| From: | liyj144 at 163 dot com | Date: | Mon, 06 May 2013 07:56:14 +0000 |
| Subject: | note 112112 added to function.strftime | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-194708@lists.php.net to get a copy of this message | ||
When i use date('W'), I found there is some problems with date like 2013-12-10, 2001-01-01
and so on.Some people suggest using strftime('%W') instead,but there is still problem if
we use the rule like this "the first week should be 1, no matter today is Monday or Tuesday or
...".At last I use this to solve the problem:
function getWeekOfYear($date_stamp){
if(date('w', strtotime(date('Y', $date_stamp).'-1-1')) == 1){
return (int)strftime('%W', $date_stamp);
}
else return (int)strftime('%W', $date_stamp)+1;
}
----
Server IP: 69.147.83.199
Probable Submitter: 222.66.115.138
----
Manual Page -- http://php.net/manual/en/function.strftime.php
Edit -- https://master.php.net/note/edit/112112
Del: integrated -- https://master.php.net/note/delete/112112/integrated
Del: useless -- https://master.php.net/note/delete/112112/useless
Del: bad code -- https://master.php.net/note/delete/112112/bad+code
Del: spam -- https://master.php.net/note/delete/112112/spam
Del: non-english -- https://master.php.net/note/delete/112112/non-english
Del: in docs -- https://master.php.net/note/delete/112112/in+docs
Del: other reasons-- https://master.php.net/note/delete/112112
Reject -- https://master.php.net/note/reject/112112
Search -- https://master.php.net/manage/user-notes.php