Welcome Guest, Not a member yet? Register   Sign In
short question: use timespan in if-clause
#1

[eluser]Jan_1[/eluser]
is there a possibility to calculate with a timespan value?

something like
Code:
$x = timespan($last, $now);
if ($x <= 60) { echo "less than an hour";}

I know, this does'nt work and i tried str_replace also... :red:

Code:
$diff_minutes = ($now - $last)/60;

But is there a smarter way with CI-helpers to calculate?
#2

[eluser]JanDoToDo[/eluser]
How about..

$result = timespan("17:56");

function timespan($last)
{
$last = strtotime($last);
if (time() - $last < 60 ) return "<60";
}




Theme © iAndrew 2016 - Forum software by © MyBB