Skip to content

Instantly share code, notes, and snippets.

@ekelleyv
Created August 3, 2012 21:07
Show Gist options
  • Save ekelleyv/3251546 to your computer and use it in GitHub Desktop.
Save ekelleyv/3251546 to your computer and use it in GitHub Desktop.
<?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