redarrow Posted February 17, 2007 Share Posted February 17, 2007 how can i set the time diffrence for 10 sec please tried everthink. please trie to use the folllowing example but correctly formatted cheers. <?php $date_now=strtotime(date("s")); $date_dif=strtotime(date("s"))-10; echo "$date_now <br> $date_dif"; if($date_now - $date_dif){ echo "done"; } ?> Link to comment https://forums.phpfreaks.com/topic/38884-date-diffrence-help/ Share on other sites More sharing options...
redarrow Posted February 17, 2007 Author Share Posted February 17, 2007 why dosent this work very strange please help. alter the code but no joy. <?php $date_now=strtotime(date("d-m-y","h:i:s")); $date_dif=strtotime(date("d-m-y","h:i:s"))-2; echo "$date_now <br> $date_dif"; if($date_now < $date_dif){ echo "done"; } ?> Link to comment https://forums.phpfreaks.com/topic/38884-date-diffrence-help/#findComment-186993 Share on other sites More sharing options...
Orio Posted February 17, 2007 Share Posted February 17, 2007 Try this: <?php $date_now=strtotime("now"); $date_dif=$date_now-10; echo "$date_now <br> $date_dif"; if($date_now > $date_dif){ echo "done"; } ?> Orio. Link to comment https://forums.phpfreaks.com/topic/38884-date-diffrence-help/#findComment-186997 Share on other sites More sharing options...
hvle Posted February 17, 2007 Share Posted February 17, 2007 $date_now = time(); $date_10seconds_later = $date_now + 10; $date_10seconds_ago = $date_now - 10; Link to comment https://forums.phpfreaks.com/topic/38884-date-diffrence-help/#findComment-186998 Share on other sites More sharing options...
o3d Posted February 17, 2007 Share Posted February 17, 2007 you could also use this longer method. $NewTime = mktime(Date("H"), Date("i"), Date("s")+10, Date("m"), Date("d"), Date("Y")); //you can now subtract from current time or do whatever with $NewTime echo Date("Y-m-d H:i:s").'(old)<br>'.Date("Y-m-d H:i:s", $NewTime).'(new)'; Link to comment https://forums.phpfreaks.com/topic/38884-date-diffrence-help/#findComment-187013 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.