Created
May 10, 2012 09:55
-
-
Save faisalman/2652218 to your computer and use it in GitHub Desktop.
Get ISO-8601 week number for a given date in PHP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Get ISO-8601 week number for a given date | |
* | |
* @author Faisalman <[email protected]> | |
* @link http://gist.github.com/faisalman | |
* @link http://en.wikipedia.org/wiki/ISO_week_date | |
* @param $y int year | |
* @param $m int month | |
* @param $d int day | |
* @return int week number | |
*/ | |
function get_weekth($y, $m, $d) | |
{ | |
return intval(date('W',strtotime($y.'-'.$m.'-'.$d))); | |
} | |
/* | |
* Usage example: | |
* echo get_weekth(2010,12,26); // 51 | |
* echo get_weekth(2011,1,1); // 52 | |
* echo get_weekth(2011,1,3); // 1 | |
*/ | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment