Skip to content

Instantly share code, notes, and snippets.

@wilsolutions
Created January 3, 2014 17:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wilsolutions/8241721 to your computer and use it in GitHub Desktop.
Save wilsolutions/8241721 to your computer and use it in GitHub Desktop.
calling Redis keys by minute in a range of minutes...
$objDateTime = new DateTime('NOW');
$this->importTime = $objDateTime->format('Y-m-d H:i:sP');
$objDateTimeAgo = new DateTime('-60 minutes');
$start = $objDateTimeAgo;
$end = $objDateTime;
$interval = DateInterval::createFromDateString('1 min');
$times = new DatePeriod($start, $interval, $end);
$totals = null;
$parsedResults = null;
$redisKey = 'analytics';
foreach ($times as $time) {
$hour = $time->format('G');
$minute = intval($time->format('i'));
$currentKey = $redisKey . ':' . $hour . ':' . $minute;
$log .= "- Current Key: " . $currentKey;
}
var_dump($log);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment