In my PHP application I want to calculate the sum of two time variables. I am looking for something like this example.
$time1 = 15:20:00;
$time2 = 00:30:00;
$time = $time1+$time2;
In my PHP application I want to calculate the sum of two time variables. I am looking for something like this example.
$time1 = 15:20:00;
$time2 = 00:30:00;
$time = $time1+$time2;
I would say just build it yourself. You can set it up like this:
$query = "INSERT INTO x (a,b,c) VALUES ";
foreach ($arr as $item) {
$query .= "('".$item[0]."','".$item[1]."','".$item[2]."'),";
}
$query = rtrim($query,",");//remove the extra comma
//execute query
Don't forget to escape quotes if it's necessary.
Also, be careful that there's not too much data being sent at once. You may have to execute it in chunks instead of all at once.
Chrome (and apparently other browsers) was looking for a favicon, or the image that appears next to the page title. As soon as I added a stock image to my page like this:
<!DOCTYPE html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon"
type="image/png"
href="https://mysite.com/icon.png">
</head>
It worked. Thanks to @dev-null-dweller for suggesting this!
You can use 24:00
or 'tomorrow midnight'
to get the next midnight. Your code use 12:00
which is "this noon".
$min = round(date("i") / 15) * 15;
$start = strtotime(date("Y-m-d H:$min:00"));
$end = strtotime('24:00');
$range = array();
while ($start <= $end)
{
echo date('h:ia',$start )."</br>";
$start = strtotime('+15 minutes',$start);
}
Will outputs:
08:15am
08:30am
...
11:30pm
11:45pm
12:00am
If you don't want to include "12:00am", you could change <=
to <
:
while ($start < $end)
The function you're looking for is find_in_set:
select * from ... where find_in_set($word, pets)
for multi-word queries you'll need to test each word and AND (or OR) the tests:
where find_in_set($word1, pets) AND find_in_set($word2, pets) etc
The best way to do this is most likely to use strtotime to convert them to timestamps and then do the adding together:
$o = strtotime($time1)+strtotime($time2);
If I remember right
strtotime
does support this format.Otherwise you will need to filter it out yourself.