Jump to content

Percentage Php Script


walapu

Recommended Posts

Hello I am wondering if someone would be willing to help me create a script, because this one is kinda complicated lol. What happens is that I specify 2 times, lets say 3:30 pm to 5:00 pm. At the beginning there will be a percent that is 0%, as time passes the percent will get higher and higher until it is at 5:00 pm. It will then be at 100%.This is for a website maintenance progress bar if you can tell.\Thanks!Also would this be better to be done in perl?

Link to comment
Share on other sites

Well, this doesn't seem too hard to do. Logical steps:

  • Define times 1 and 2, how complicated this is depends on your requirements, possibly involving a database for ease of use
  • Check if time 1 has arrived yet, if not handle case that time period has yet to arrive
  • Check if we're later than time 2, if so the time period has already elapsed
  • If neither of the previous were true then we handle the case that we are in that time period, subtract time 1 from time 2 (as unix timestamps) (result is sum 1), subtract time 1 from time() (result is sum 2), 100*(sum1-sum2) is the percentage

Which bit of that are you unsure of? Perl would be better if you're familiar with perl I suppose, if you're more familiar with PHP and the app is written in it then there's no compelling advantage to mix languages.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...