Forum Moderators: coopster
Example: I want the code to keep counting down 15 days. Not from a specific date but just literally 15 days. Which is 360hrs.
How would I get something like:
<?php
$target = mktime(0, 0, 0, 2, 10, 2007) ;
$today = time () ;
$difference =($target-$today) ;
$days =(int) ($difference/86400) ;
print "Our event will occur in $days days";
?>
to do what I need it to do?
Thanks!
MM
Try this:
<?php
$start = mktime(0, 0, 0, 9, 17, 2008);
$target = $start+15*60*60*24; //15 days from start
$now = time();$difference =($target-$now);
$days =(int) ($difference/86400) ;
print "Our event will occur in $days days";
?>
So essentially no matter what I do, or how I code it I will still have to come in and change the date?
Not necessarily, but at some point you're going to have to set the count to 0 and store the count of days (more work and possibly less accurate - you need to use a CRON job or something and save the count in a file). Best storing a start date.
How would you envisage counting the number of days, if you didn't have a start date or reset count to 0? How would you know you were on day 5 for instance? If you didn't use a start date, your script would have to run at least once a day in order to update the count. With a start date that's not important.