Question: Hello: I have a code here to output the quarter in the current time. My question is , what is the syntax: $min=substr($time,3,2); $sec=substr($time,6,2); Could
Hello:
I have a code here to output the quarter in the current time.
//variables
$min;
$sec;
//setting timezone for getting time
date_default_timezone_set('America/Chicago');
$time = date('H:i:s'); //H= hour(using 24 hours), i=min , s=sec
$min=substr($time,3,2);
$sec=substr($time,6,2);
echo "Time-".$time;
echo "
Minute: ".$min;
echo "
Second: ".$sec;
if(($min>=00)&&($min<=14)){
if($sec<=59)
echo"
We are in First Quarter of Hours";
}
elseif(($min>=15)&&($min<=29)){
if($sec<=59)
echo"
We are in Second Quarter of Hours";
}
elseif(($min>=30)&&($min<=44)){
if($sec<=59)
echo"
We are in Third Quarter of Hours";
}
else{
if($sec<=59)
echo"
We are in Fourth Quarter of Hours";
}
?>
My question is , what is the syntax: $min=substr($time,3,2);
$sec=substr($time,6,2);
Could you please explain to me? ( we are not allowed to use any MYSqual function)
Thank you!
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
