2
$\begingroup$

I want to create a progressbar which progress (in %) is influenced by the time between a timestamp in the past.

Timestamp one would be 1382377800.

Timestamp two would be 1382377860

Those are 60 seconds. The first one should represent 0%, the other one 100%.

I know I have to divide it somehow and multiply it, but can't figure it out.

1382377830 should be 50% then :i

$\endgroup$
  • $\begingroup$ Try $1382377800+0.5 (1382377860-1382377800)$. Adjust $0.5$ accordingly... $\endgroup$ – copper.hat Oct 21 '13 at 22:25
  • $\begingroup$ I am sorry but the result is not what I wanted. I want to get a percentage like 0.5, not a real number. $\endgroup$ – user102389 Oct 21 '13 at 22:27
  • 1
    $\begingroup$ Hmm, you need to do a little work here. Try $\frac{1382377830-1382377800}{1382377860-1382377800}$. $\endgroup$ – copper.hat Oct 21 '13 at 22:29
  • 1
    $\begingroup$ Consider this as well. $\endgroup$ – abiessu Oct 21 '13 at 22:30
1
$\begingroup$

To find the percentage of 60 you've progressed past timestamp 1, simply subtract timestamp 1 from timestamp 2 to find the elapsed time and divide by 60. so: $$p = \frac{(T2 - T1)}{60}$$

Where T1 is the first timestamp, T2 is the second, and p is the percentage you're looking for.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.