Setting Time in C

Discussion in 'C Programming' started by Jimmy, Oct 6, 2003.

  1. Jimmy

    Jimmy Guest

    Hello,

    Can anyone tell me how to set the time using C code? After browsing through
    MSDN, I only find the C command to get time and not set time. Can anyone
    advise me on this??


    --
    Regards

    Jimmy Lim
     
    Jimmy, Oct 6, 2003
    #1
    1. Advertising

  2. I believe you want to set system time, right?
    There is settimeofday() similar to gettimeofday().
    But it says you have to be the system administrator to do that, else it
    will fail.

    Jimmy wrote:
    > Hello,
    >
    > Can anyone tell me how to set the time using C code? After browsing through
    > MSDN, I only find the C command to get time and not set time. Can anyone
    > advise me on this??
    >
    >
     
    Pushkar Pradhan, Oct 6, 2003
    #2
    1. Advertising

  3. Jimmy

    Jimmy Guest

    Thanks for the information. ^_^

    --
    Regards

    Jimmy Lim

    "Pushkar Pradhan" <> wrote in message
    news:...
    > I believe you want to set system time, right?
    > There is settimeofday() similar to gettimeofday().
    > But it says you have to be the system administrator to do that, else it
    > will fail.
    >
    > Jimmy wrote:
    > > Hello,
    > >
    > > Can anyone tell me how to set the time using C code? After browsing

    through
    > > MSDN, I only find the C command to get time and not set time. Can anyone
    > > advise me on this??
    > >
    > >

    >
     
    Jimmy, Oct 6, 2003
    #3
  4. Jimmy

    Mike Wahler Guest

    "Pushkar Pradhan" <> wrote in message
    news:...
    > I believe you want to set system time, right?
    > There is settimeofday() similar to gettimeofday().


    C has no such functions.


    > But it says you have to be the system administrator to do that, else it
    > will fail.


    C has no concept of 'system administrator'.

    Please keep platform-specific issues out of this
    ISO standard C language group.

    -Mike
     
    Mike Wahler, Oct 6, 2003
    #4
  5. Jimmy

    Mike Wahler Guest

    Re: [OT] Setting Time in C

    "Jimmy" <> wrote in message
    news:blr0a1$toi$...
    > Hello,
    >
    > Can anyone tell me how to set the time using C code?


    There is no way. C does not require the host platform
    to have a clock at all.

    > After browsing through
    > MSDN,



    MSDN does not define or document the C language, but
    Microsoft products.

    >I only find the C command


    C has no commands.

    >to get time and not set time. Can anyone
    > advise me on this??


    The C standard library provides a function called
    'time()' which can retrieve a system clock's time
    *if* such a system clock exists. There is no
    C function which can alter the state of a system's
    clock.

    You'll need platform-specific tools. You mention MSDN.
    If you're wanting to do this on a Windows system, then
    yes, there are indeed Microsoft functions for accessing
    and modifying the state of the system clock.

    But platform specific issues are not topical here.
    The answer is indeed there at the MSDN site, all
    you have to do is look. It's also described in the
    documentation of the Windows API, provided with
    virtually all Windows compilers.

    -Mike
     
    Mike Wahler, Oct 6, 2003
    #5
  6. Jimmy

    Jimmy Guest

    Re: [OT] Setting Time in C

    Thanks

    --
    Regards

    Jimmy Lim

    "Mike Wahler" <> wrote in message
    news:aQbgb.23$...
    >
    > "Jimmy" <> wrote in message
    > news:blr0a1$toi$...
    > > Hello,
    > >
    > > Can anyone tell me how to set the time using C code?

    >
    > There is no way. C does not require the host platform
    > to have a clock at all.
    >
    > > After browsing through
    > > MSDN,

    >
    >
    > MSDN does not define or document the C language, but
    > Microsoft products.
    >
    > >I only find the C command

    >
    > C has no commands.
    >
    > >to get time and not set time. Can anyone
    > > advise me on this??

    >
    > The C standard library provides a function called
    > 'time()' which can retrieve a system clock's time
    > *if* such a system clock exists. There is no
    > C function which can alter the state of a system's
    > clock.
    >
    > You'll need platform-specific tools. You mention MSDN.
    > If you're wanting to do this on a Windows system, then
    > yes, there are indeed Microsoft functions for accessing
    > and modifying the state of the system clock.
    >
    > But platform specific issues are not topical here.
    > The answer is indeed there at the MSDN site, all
    > you have to do is look. It's also described in the
    > documentation of the Windows API, provided with
    > virtually all Windows compilers.
    >
    > -Mike
    >
    >
     
    Jimmy, Oct 6, 2003
    #6
  7. Jimmy

    Dan Pop Guest

    In <blr0a1$toi$> "Jimmy" <> writes:

    >Can anyone tell me how to set the time using C code? After browsing through
    >MSDN, I only find the C command to get time and not set time. Can anyone
    >advise me on this??


    The C language has no facility for doing this. Your OS's API probably
    provides a way of doing it. Your reference to MSDN suggests that
    comp.os.ms-windows.programmer.win32 is the right newsgroup for asking.

    Dan
    --
    Dan Pop
    DESY Zeuthen, RZ group
    Email:
     
    Dan Pop, Oct 6, 2003
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Srinivasa Raghavan Sethuraman
    Replies:
    0
    Views:
    562
    Srinivasa Raghavan Sethuraman
    Jun 30, 2004
  2. engsol
    Replies:
    2
    Views:
    953
    Dan Bishop
    Jan 26, 2004
  3. Replies:
    8
    Views:
    478
    Magnus Lycka
    Aug 5, 2005
  4. Peter Hansen
    Replies:
    0
    Views:
    716
    Peter Hansen
    Feb 22, 2006
  5. flamesrock
    Replies:
    8
    Views:
    470
    Hendrik van Rooyen
    Nov 24, 2006
Loading...

Share This Page