date

Secţiune dedicată începatorilor.

Moderatori: Moderatori, Start Moderator

nimeni
PHPRomania Supporter
Mesaje: 12
Membru din: Vin Ian 22, 2010 8:59 am

date

Mesajde nimeni » Joi Mar 11, 2010 3:06 pm

$ot = $row['onlinetime'];
$hours = floor($ot/3600);
$min = floor(($ot - $hours*3600)/60);
$sec = $ot - $hours*3600 - $min*60;
$days = floor($hours/24);

si iese cam asa:

N? Name
1 Adidas 1 days, 30 hours, 26 minutes, 45 seconds

ma refer la ore ... trebuia sa ramana ce este peste 24
ms ptr ajutor



doro69
PHPRomania Supporter
Mesaje: 16
Membru din: Joi Sep 10, 2009 1:27 pm
Localitate: Bucuresti

Mesajde doro69 » Joi Mar 11, 2010 5:39 pm


nimeni
PHPRomania Supporter
Mesaje: 12
Membru din: Vin Ian 22, 2010 8:59 am

Mesajde nimeni » Sâm Mar 13, 2010 5:30 am


flopyse
PHPRomania Supporter
Mesaje: 5
Membru din: Vin Mar 12, 2010 9:44 pm

Mesajde flopyse » Sâm Mar 13, 2010 8:04 am

$ot = $row['onlinetime'];
$days = floor($ot/24);
$hours = floor(($ot - $days*24)/3600);
$min = floor(($ot - $hours*3600)/60);
$sec = $ot - $hours*3600 - $min*60;

nimeni
PHPRomania Supporter
Mesaje: 12
Membru din: Vin Ian 22, 2010 8:59 am

Mesajde nimeni » Dum Mar 14, 2010 8:04 am


flopyse
PHPRomania Supporter
Mesaje: 5
Membru din: Vin Mar 12, 2010 9:44 pm

Mesajde flopyse » Dum Mar 14, 2010 10:33 am

Da corect :) uite o varianta putin modificata

$then = $row['onlinetime'];
$now = date("U");

$ot = $now - $then;
$days = floor($ot/86400);

$ot = $ot - ($days*86400);
$hours = floor($ot/3600);
$ot = $ot - ($hours*3600);
$min = floor($ot/60);
$sec = $ot - ($min*60);

nimeni
PHPRomania Supporter
Mesaje: 12
Membru din: Vin Ian 22, 2010 8:59 am

Mesajde nimeni » Lun Mar 15, 2010 4:50 am


flopyse
PHPRomania Supporter
Mesaje: 5
Membru din: Vin Mar 12, 2010 9:44 pm

Mesajde flopyse » Lun Mar 15, 2010 8:02 am

In ce format ai data trecuta? Ar trebui sa o ai in format unix(adica 1268631916 reprezentand numarul de secunde scurse de la 1 ianuarie 1970) eu varianta aia am testat-o si merge...daca nu este incearca cu
$then = date(mktime(ore, minute, secunde, luna, zi, an));

Sau daca ai in variabila doar numarul de secunde de cand este online...atunci:

$ot = $row['onlinetime'];

$days = floor($ot/86400);

$ot = $ot - ($days*86400);
$hours = floor($ot/3600);
$ot = $ot - ($hours*3600);
$min = floor($ot/60);
$sec = $ot - ($min*60);


Înapoi la “PHP Incepători”

Cine este conectat

Utilizatori ce ce navighează pe acest forum: Niciun utilizator înregistrat și 20 vizitatori