note 106974 added to function.date
| From: | Jimmy at osu1 dot php dot net | Date: | Thu, 22 Dec 2011 13:04:05 +0000 |
| Subject: | note 106974 added to function.date | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-185204@lists.php.net to get a copy of this message | ||
Things to be aware of when using week numbers with years.
<?php
echo date("YW", strtotime("2011-01-07")); // gives 201101
echo date("YW", strtotime("2011-12-31")); // gives 201152
echo date("YW", strtotime("2011-01-01")); // gives 201152 too
?>
BUT
<?php
echo date("oW", strtotime("2011-01-07")); // gives 201101
echo date("oW", strtotime("2011-12-31")); // gives 201152
echo date("oW", strtotime("2011-01-01")); // gives 201052 (Year is different
than previous example)
?>
Reason:
Y is year from the date
o is ISO-8601 year number
W is ISO-8601 week number of year
Conclusion:
if using 'W' for the week number use 'o' for the year.
----
Server IP: 69.147.83.197
Probable Submitter: 142.176.222.78
----
Manual Page -- http://www.php.net/manual/en/function.date.php
Edit -- https://master.php.net/note/edit/106974
Del: integrated -- https://master.php.net/note/delete/106974/integrated
Del: useless -- https://master.php.net/note/delete/106974/useless
Del: bad code -- https://master.php.net/note/delete/106974/bad+code
Del: spam -- https://master.php.net/note/delete/106974/spam
Del: non-english -- https://master.php.net/note/delete/106974/non-english
Del: in docs -- https://master.php.net/note/delete/106974/in+docs
Del: other reasons-- https://master.php.net/note/delete/106974
Reject -- https://master.php.net/note/reject/106974
Search -- https://master.php.net/manage/user-notes.php