Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Timer for Minute, Hours & days..

Timer for Minute, Hours & days..

Scheduled Pinned Locked Moved C / C++ / MFC
comhelptutorial
7 Posts 6 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Sumit Kapoor
    wrote on last edited by
    #1

    Hi..can anybody..suggest me How to make timer for 1. Minute 2. Hours 3. days i.e. User set a time for process to execute after 10 min. then after 10 min. a event is fired & process start running.. this 10 min. can be 10 days... Plz suggest me how to go next..as I didn't find any timer that even deals with min. or hours..even days r too far. evry timer is based on milisecond..that i don't want... I hope u'll help me.. Thanks ---Sumit Kapoor--- sumit_kapoor1980@hotmail.com

    L RaviBeeR T V 4 Replies Last reply
    0
    • S Sumit Kapoor

      Hi..can anybody..suggest me How to make timer for 1. Minute 2. Hours 3. days i.e. User set a time for process to execute after 10 min. then after 10 min. a event is fired & process start running.. this 10 min. can be 10 days... Plz suggest me how to go next..as I didn't find any timer that even deals with min. or hours..even days r too far. evry timer is based on milisecond..that i don't want... I hope u'll help me.. Thanks ---Sumit Kapoor--- sumit_kapoor1980@hotmail.com

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      1000ms = 1sec 60sec = 1min 60mins = 1hour 24hours = 1day 7days = 1week got the point? what's wrong with a timer interval of (1000 * 60 * 10) for 10 minutes (just as an example)? You can safely use SetTimer. There are not "timers for days/minutes" that I'm aware of. regards

      S 1 Reply Last reply
      0
      • L Lost User

        1000ms = 1sec 60sec = 1min 60mins = 1hour 24hours = 1day 7days = 1week got the point? what's wrong with a timer interval of (1000 * 60 * 10) for 10 minutes (just as an example)? You can safely use SetTimer. There are not "timers for days/minutes" that I'm aware of. regards

        S Offline
        S Offline
        Sumit Kapoor
        wrote on last edited by
        #3

        thanks for reply.. But there must be limit to pass vaue of time in SetTimer function..I'm not sure but that must be 65,000ms this means I can do with 10 min. interval..but when I wish to do with days interval then it would be problem for program to check over & again... do u have any idea.. Thanks..bye sumit_kapoor1980@hotmail.com

        R 1 Reply Last reply
        0
        • S Sumit Kapoor

          Hi..can anybody..suggest me How to make timer for 1. Minute 2. Hours 3. days i.e. User set a time for process to execute after 10 min. then after 10 min. a event is fired & process start running.. this 10 min. can be 10 days... Plz suggest me how to go next..as I didn't find any timer that even deals with min. or hours..even days r too far. evry timer is based on milisecond..that i don't want... I hope u'll help me.. Thanks ---Sumit Kapoor--- sumit_kapoor1980@hotmail.com

          RaviBeeR Offline
          RaviBeeR Offline
          RaviBee
          wrote on last edited by
          #4

          You could use a couple of CTime objects to keep track of the start and current time. The start time is set when your program starts (you can do this in your dialog's OnInitDialog() handler). Set a timer to fire every second (since this is the resolution you want to honor) and in your OnTimer() handler, do the following:

          CTime tmNow = CTime::GetCurrentTime();
          int nElapsedSeconds = tmNow.GetTime() - tmStart.GetTime();
          if (nElapsedSeconds > ...) {
          // Time to do something...
          }

          /ravi My new year's resolution: 2048 x 1536 Home | Articles | Freeware | Music ravib@ravib.com

          1 Reply Last reply
          0
          • S Sumit Kapoor

            thanks for reply.. But there must be limit to pass vaue of time in SetTimer function..I'm not sure but that must be 65,000ms this means I can do with 10 min. interval..but when I wish to do with days interval then it would be problem for program to check over & again... do u have any idea.. Thanks..bye sumit_kapoor1980@hotmail.com

            R Offline
            R Offline
            Ryan Binns
            wrote on last edited by
            #5

            Sumit Kapoor wrote: But there must be limit to pass vaue of time in SetTimer function..I'm not sure but that must be 65,000ms Nope, it's about 4 billion ms...

            Ryan

            "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"

            1 Reply Last reply
            0
            • S Sumit Kapoor

              Hi..can anybody..suggest me How to make timer for 1. Minute 2. Hours 3. days i.e. User set a time for process to execute after 10 min. then after 10 min. a event is fired & process start running.. this 10 min. can be 10 days... Plz suggest me how to go next..as I didn't find any timer that even deals with min. or hours..even days r too far. evry timer is based on milisecond..that i don't want... I hope u'll help me.. Thanks ---Sumit Kapoor--- sumit_kapoor1980@hotmail.com

              T Offline
              T Offline
              ThatsAlok
              wrote on last edited by
              #6

              the simple code is this CString m_szCurrentTime; CTime time=CTime::GetCurrentTime(); m_szCurrentTime.Format("%d : %d : %d",time.GetHour(),time.GetMinute(),time.GetSecond()); I Think It will Work ----------------------------- Alok Gupta visit me at http://www.thisisalok.tk

              1 Reply Last reply
              0
              • S Sumit Kapoor

                Hi..can anybody..suggest me How to make timer for 1. Minute 2. Hours 3. days i.e. User set a time for process to execute after 10 min. then after 10 min. a event is fired & process start running.. this 10 min. can be 10 days... Plz suggest me how to go next..as I didn't find any timer that even deals with min. or hours..even days r too far. evry timer is based on milisecond..that i don't want... I hope u'll help me.. Thanks ---Sumit Kapoor--- sumit_kapoor1980@hotmail.com

                V Offline
                V Offline
                V 0
                wrote on last edited by
                #7

                Yup, I think CTime and CTimeSpan are the way the go. Look them up on msdn. You'll figure it out. Good luck! "If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimi Hendrix

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups