Oppure

Loading
17/12/09 19:56
Raffa50
Salve! vorrei fare un piccolo script ke è in grado di fare la differenza di 2 date (con ore).
Questo lo volgio utilizzare per capire quanto tempo è passato da un login all'altro...

Se per esempio mi sono loggato il 10/12/2009 alle 18:01:23 e ritorno il 17/12/2009 alle 20:50, voglio sapere quanto è passato (in minuti)

ho provato a fare uno script, ma senza sucesso... aiuto... grazie!
aaa
18/12/09 8:36
Thejuster
un ottimo esempio trovato con google


<?php 
$DateOfRequest = date("Y-m-d H:i:s", mktime($_REQUEST["Hour"],$_REQUEST["Min"],$_REQUEST 
["Sec"],$_REQUEST["Month"],$_REQUEST["Day"],$_REQUEST["Year"]));            
?>



ti basta usare l'array per ottere quello che ti serve,
dal giorno/mese/anno o da minuti secondi e ore
Ultima modifica effettuata da Thejuster 18/12/09 8:37
mire.forumfree.it/ - Mire Engine
C# UI Designer
18/12/09 12:50
cassin.simone
E' molto difficile creare uno script del genere ma non impossibile. A mio avviso ci vorrebbe un algoritmo apposito per sapere appunto quanto tempo è trascorso...
Quoto quindi Thejuster
aaa
18/12/09 13:04
Raffa50
Ma quello non fà la differenza... io c'ho provato ekko lo script

<?php
//giorni registrati
$dr=15;
$mr=12;
$yr=2009;
//ore registrate
$hr=20;
$mr=45;
$sr=00;
//data oggi
$dt=date("j");
$mt=date("n");
$yt=date("y");
//ore oggi
$timenow=getdate();
$hn=substr("0" . $timenow["hours"], -2);
$mh=substr("0" . $timenow["minutes"], -2);
$sn=substr("0" . $timenow["seconds"], -2);
//data e ora
$ktimer=mktime($hr,$mr,$sr,$mr,$dr,$yr);  //data e ora sul db pronto per le operazioni!
$mtimet=mktime($hn,$mh,$sn,$mt,$dt,$yt); //data e ora oggi pronto per le operazioni e per il db!
$diffd=intval(($ktimer-$mtimet)/(60*60*60*24));

echo $diffd;
?>


e non funziona... aiuto...
aaa
20/12/09 10:31
Raffa50
ci sono riuscito!

<?php
//giorni registrati
$rdr=19;
$rmr=12;
$ryr=2009;
//ore registrate
$rhr=11;
$rmir=15;
$rsr=00;
//data oggi
$dt=date("j");
$mt=date("n");
$yt=date("y");
//ore oggi
$timenow=getdate();
$hn=substr("0" . $timenow["hours"], -2);
$mih=substr("0" . $timenow["minutes"], -2);
$sn=substr("0" . $timenow["seconds"], -2);
//data e ora
$ktimer=mktime($rhr,$rmir,$rsr,$rmr,$rdr,$ryr);  //data e ora sul db pronto per le operazioni!
$mtimet=mktime($hn,$mih,$sn,$mt,$dt,$yt); //data e ora oggi pronto per le operazioni e per il db!
$diffd=intval(($mtimet-$ktimer)/(60));


echo $diffd;
?>
aaa
20/12/09 10:35
cassin.simone
Benissimo!
aaa