Jump to content

[SOLVED] visualize Countdown


DEVILofDARKNESS

Recommended Posts

Okay so I'm building a game, (it's almost finished), but a friend of me said it would be better that if you bought a building or Weapon (on the game) that instead of having the item direct a counter should appear. this one should countdown from a certain time in minutes or houres till zero and you should be possible to see it count down,

 

if you quit the browser the counter actually should go on, so that if you come back it could be build

 

Only one problem: I really have NO idea how I should do this. :s

Link to comment
https://forums.phpfreaks.com/topic/173804-solved-visualize-countdown/
Share on other sites

One approach would be to store the time of the purchase, and calculate the time it will be "ready" and store that... then, when they were to go to use it, you would check that ready time first to see if it is available for use.

 

You could use javascript to build a countdown timer... and feed it the value of the ready time to countdown to... then if they closed and left, it would just get the ready time from the database and continue counting down upon their return.

 

Hope that helps :)

Okay, so I would determine when it should be finished, by doing the current time + the ammount of minutes needed and store this value in a database.

Okay I got that,

 

but I don't know anything about javascript (except the alert function :P) so how should I do this?

Okay I found this javascript

<script language="JavaScript">
TargetDate = "12/31/2020 5:00 AM";
BackColor = "palegreen";
ForeColor = "navy";
CountActive = true;
CountStepper = -1;
LeadingZero = true;
DisplayFormat = "%%D%% Days, %%H%% Hours, %%M%% Minutes, %%S%% Seconds.";
FinishMessage = "It is finally here!";
</script>

 

but how can I pass hte value of php to javascript

TargetDate = <?php echo $targetdate; ?>

???

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.