CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2010
    Posts
    1

    Use modulus operator to convert time

    I need to convert hours into weeks, days, and hours.

    My professor was hinting that there might be a way to
    do this using the modulus operator but I can't seem to think of a way
    that its possible. Can anyone help?

    thanks!

  2. #2
    Join Date
    Jan 2008
    Location
    California, USA
    Posts
    822

    Re: Use modulus operator to convert time

    Hi jhus00

    modulus operator returns the remainder of the division. you already know this correct?

    EDIT:
    the first step is to define end goal of your program.
    you can show us, either in real or psuedo code, or written statement, how you would define this end goal.

    and don't forget to wrap your code inside [code] your code goes here[/code]
    Last edited by potatoCode; January 20th, 2010 at 10:56 PM.

  3. #3
    Join Date
    Jan 2009
    Posts
    1,689

    Re: Use modulus operator to convert time

    Well, the time_t structures is seconds since Jan 1st, 1970 at midnight GMT. There are 60 seconds in a minute, so time % 60 will give you the current seconds. From there you should be able to figure it out.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured