Skip to content

Instantly share code, notes, and snippets.

@Maxghp
Created April 4, 2016 11:16
Show Gist options
  • Select an option

  • Save Maxghp/87924fb92585039db1237bab28d1706c to your computer and use it in GitHub Desktop.

Select an option

Save Maxghp/87924fb92585039db1237bab28d1706c to your computer and use it in GitHub Desktop.
$res = $this->dbAdapter->query("SELECT location FROM users WHERE user_id=:user_id")->execute([
':user_id'=>$user_id,
])->getResource()->fetchAll();
if(!empty($res)){
$loc = $res[0]['location'];
}
if(!empty($loc)){
if($loc == 'Toronto'){
$x = array(18900, 36000);
//count time
list($h,$m) = explode(":", $total['total']);
$min = ($h*60)+$m;
$sec = ($min*60);
if($x[0] > $sec){
$seconds = ($sec + 299);
$time = new DateTime('@'.$seconds);
$timeT ='+' . $time->format('H:i');
}else if(($sec > $x[0]) && ($sec < $x[1])){
$seconds = $sec - 1548;
$time = new DateTime('@'.$seconds);
$timeT ='-' . $time->format('H:i');
}else if($sec > $x[1]){
$seconds = $sec - 3420;
$time = new DateTime('@'.$seconds);
$timeT ='-' . $time->format('H:i');
}
}else{
$timeT = 'NULL';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment