Jump to content

[RESOLVIDO, mas aceito melhoramento] Comparar strtotime()


cra2sh
 Share

Recommended Posts


$change = strtotime(date('2012-12-02 23:35:00'));
$now = strtotime(date('Y-m-d H:i:s'));

$date = date('H:i:s', ($now - $change));
return $date;

Criei esta função aqui em cima mas o resultado é sempre 1h a mais do que o esperado, a ideia é comprar o resultado e se for inferior a 5min = 1resultado, se for superior = 2resultado,

Alguém me pode ajudar?

Edited by cra2sh
Link to comment
Share on other sites

Já resolvi


while($row = mysqli_fetch_assoc($online_check_query)) {
$change = $row['user_last_change'];
};

$change = strtotime(date('Y-m-d H:i:s', strtotime($change)));
$date = strtotime(date('Y-m-d H:i:s', (time() - $change)));

if ($date > (5 * 60)) {
$status = 'ausente';
} else {
$status = 'online';
};

Se alguém tiveres ai ideia para melhor este código que chute xD

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.