Created
January 21, 2013 13:37
-
-
Save Ahrengot/4586100 to your computer and use it in GitHub Desktop.
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
/*-----------------------------------------------------------------------------------*/ | |
/* FIGURE OUT WHEN CONCERTS PLAY | |
/*-----------------------------------------------------------------------------------*/ | |
function get_concert_timeframe($timestamp) { | |
// Time filter (next weekend, 30 days, next year etc.) | |
$time = ''; | |
$next_monday = strtotime("next Monday"); | |
$weekend_start = strtotime("next Friday"); | |
$next_month = strtotime("+1 month"); | |
$next_six_months = strtotime("+6 months"); | |
// Check if today is a weekend-day. If it is, then change $weekend_start to today. | |
// Minus any time that has passed today. Ie. count from the beginning of today. | |
$today = date('D', strtotime('now')); | |
if ($today == 'Fri' OR $today == 'Sat' OR $today == 'Sun') $weekend_start = strtotime('today'); | |
if ($timestamp < strtotime('tomorrow 00:00') AND $timestamp >= strtotime('today 00:00')) $time.= 'today '; | |
if ($timestamp < $next_monday AND $timestamp >= $weekend_start) $time .= 'next_weekend '; | |
if ($timestamp < $next_month) $time .= 'next_month '; | |
if ($timestamp < $next_six_months) $time .= ' next_six_months'; | |
// Reset string if concert already played, but wasn't deleted yet | |
if (strtotime("-1 day") > $timestamp) $time = 'already_played'; | |
return $time; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment