Created
August 11, 2012 18:50
-
-
Save robertjmoore/3326340 to your computer and use it in GitHub Desktop.
Generate a string detailing all the cohorts a given user belongs to
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 | |
function getQuarter() { | |
$monthNumber = intval(date("m")); | |
return floor(($monthNumber - 1) / 3) + 1; | |
} | |
function buildWeek() { | |
if (date('l') == "Sunday") { | |
$sundayTime = time(); | |
} | |
else { | |
$sundayTime = strtotime('last sunday'); | |
} | |
$WY = date("Y", $sundayTime); | |
$WM = date("m", $sundayTime); | |
$WD = date("d", $sundayTime); | |
return sprintf("WY:%s;WM:%s;WD:%s;", $WY, $WM, $WD); | |
} | |
function getTimeString() { | |
return sprintf("Y:%s;Q:%s;M:%s;%sD:%s;H:%s", date("Y"), getQuarter(), date("m"), buildWeek(), date("d"), date("H")); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment