PHPMine
<? if(PHP > $Expectations) echo $Results ?>
by Angel S. Moreno
UNDER SOME SERIOUS CONSTRUCTION LINKS MAY NOT WORK
Asked 2010-03-16 20:30:33 by Four
I am attempting to create a php script that counts down to an event that happens next year, and I am having some trouble. The day I need to count down to is February 28th, however I am having some issues getting started. I understand that I should be using the mktime function in some form, but I have no idea on how to get it to calculate the number of days, hours, and minutes to the date.
Anwered 2010-03-16 22:21:48 by Robin T
$epochTimeOnFeb28 = strtotime('2011-02-28');
$epochTimeNow = time();
$noOfSecondsUntilFeb28 = $epochTimeOnFeb28 - $epochTimeNow;
$noOfDaysUntilFeb28 = floor($noOfSecondsUntilFeb28 / (24 * 60 * 60));
$hours = floor(($noOfSecondsUntilFeb28 % (24 * 60 * 60)) / 3600);
I'll let you figure out how to find the minutes from there :)
More info regarding the functions used:
- http://php.net/strtotime
- http://php.net/time
- http://php.net/floor
Anwered 2010-03-16 21:08:28 by Ecureuil
from my understanding php is a server side only language? i might be wrong.. i haven't used it in years.. but basically..
If you want a count down script where you actually see the seconds tick down, you'll want to use JavaScript.. you can use it on your php page.. so.. what you'd do is.. javascript can be added to your page like HTML and it is rendered on client side like HTML.. in fact you insert javascript into the page using html!
<script type="text/javascript">alert("this is my javascript");</script>
Basically the difference is... php is ran on the server, and sent to the client, and the client pages can't see the code.. javascript is rendered on the client, and the client can see the code.
If you want a countdown script to the date.. i'm sure you can find countless javascript countdown scripts out there.
Questions and answers provided by the Yahoo Answers Community.