We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now


online Timer

dapple asked
Medium Priority
Last Modified: 2010-04-04
I need a online timer algorithm that calculates the time zone i am in and works out a cost for that second, it is for a program that claculates the online time spent on the internet and gives a real time cost per second, it is for a school project i have to give in soon, pleeeeasssseeee help. It should give the duration and the total cost for that time worked out by the second. Please mail me
Watch Question

Unlock this solution with a free trial preview.
(No credit card required)
Get Preview


Zifnab you misunderstood This does not answer my question
i mean i want to work out the amount of time i have spent onlne
and a cost per second in real time for that duration. I need to know which time zone i am in i.e 08:00 - 18:00 peak rate or
18:00 - 8:00 evening rate, this should be calculated every sec
then charge an amount for that second. So it will give a start time for the call a duration and a cost every second.


Ok, then what do you already know.

Do you have some strategy? What values are user put-ins? Are the time-zones entered by the user? What do you need to know, without  input from the user.



The user inputs the peak start time and finish time e.g.
08:00 - 18:00 also the cost per min for each period peak, evening, weekend e.g 3 pence/min. The app then gives the start time when the DUN starts a duration since the start and the current cost using the value the user entered. I want to know the algorithm for working this cost out.
I tried increment a variable every sec to represent the number of seconds in each time zone e.g.
18:00 - 23:59 inc(daysec) then use the number of secs to work the cost but this was not accurate i need to use the start time and endtime to work it. How would you go about it?

? dapple, I think I still don't fully understand your problem.
Why not using the Time function which returns the current time?

1. When DUN starts, put the current time in a variable, look in which time-period you are
2. Then get your new time (every second in your case), look in which time-period you are for this new time.
 - in the same  : (TimeNew-TimeStart) in minutes * money = ...
 - in different : First calculate the previous cost
                  + New cost, because new time-period.



Am I missing something?


ok no problem i will try and work it thanks for your time

dapple, you didn't have to accept my answer already, first try it out!! Zif. Let me know when you've some problems.
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a free trial preview!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.