PHP Date difference -


i've following code:

$dstart = new datetime('2013-03-15'); $dend = new datetime('2013-04-01'); $ddiff = $dstart->diff($dend); echo $ddiff->days; 

i don't know why i'm getting 6015 result.

try like

$dstart = strtotime('2013-03-15'); $dend = strtotime('2013-04-01'); $ddiff = $dend - $dstart; echo date('h:i:s',$ddiff); 

or per code try with

$ddiff = $dstart->diff($dend); $date->format('d',$ddiff); echo $ddiff->days; 

if want diff in days try also

echo floor($ddiff/(60*60*24)); 

Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -