Skip to content

Instantly share code, notes, and snippets.

@Maxghp
Created April 1, 2016 11:41
Show Gist options
  • Select an option

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

Select an option

Save Maxghp/a8e878e9ca2fb740e923a04e9be706f9 to your computer and use it in GitHub Desktop.
//gist work with time
$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;
$timeT = '+' . date('H:i:s',$seconds);
}else if(($sec > $x[0]) && ($sec < $x[1])){
$seconds = $sec - 1548;
$timeT = '-' . date('H:i:s',$seconds);
}else if($sec > $x[1]){
$seconds = $sec - 3420;
$timeT = '-' . date('H:i:s',$seconds);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment