Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Setting Time in C

Reply
Thread Tools

Setting Time in C

 
 
Jimmy
Guest
Posts: n/a
 
      10-06-2003
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


 
Reply With Quote
 
 
 
 
Pushkar Pradhan
Guest
Posts: n/a
 
      10-06-2003
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??
>
>


 
Reply With Quote
 
 
 
 
Jimmy
Guest
Posts: n/a
 
      10-06-2003
Thanks for the information. ^_^

--
Regards

Jimmy Lim

"Pushkar Pradhan" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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??
> >
> >

>



 
Reply With Quote
 
Mike Wahler
Guest
Posts: n/a
 
      10-06-2003

"Pushkar Pradhan" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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


 
Reply With Quote
 
Mike Wahler
Guest
Posts: n/a
 
      10-06-2003

"Jimmy" <(E-Mail Removed)> wrote in message
news:blr0a1$toi$(E-Mail Removed)...
> 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


 
Reply With Quote
 
Jimmy
Guest
Posts: n/a
 
      10-06-2003
Thanks

--
Regards

Jimmy Lim

"Mike Wahler" <(E-Mail Removed)> wrote in message
news:aQbgb.23$(E-Mail Removed) et...
>
> "Jimmy" <(E-Mail Removed)> wrote in message
> news:blr0a1$toi$(E-Mail Removed)...
> > 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
>
>



 
Reply With Quote
 
Dan Pop
Guest
Posts: n/a
 
      10-06-2003
In <blr0a1$toi$(E-Mail Removed)> "Jimmy" <(E-Mail Removed)> 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: http://www.velocityreviews.com/forums/(E-Mail Removed)
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is time.time() < time.time() always true? flamesrock Python 8 11-24-2006 06:51 AM
Re: interpreting the fractional portion of time.clock() vs time.time()measurements Peter Hansen Python 0 02-22-2006 12:03 AM
time.clock() or time.time() peterbe@gmail.com Python 8 08-05-2005 01:51 PM
Setting a configurable time-out setting for all the communication initiated with Remoting object. Srinivasa Raghavan Sethuraman ASP .Net 0 06-30-2004 10:05 AM
delta time = time stop - time start engsol Python 2 01-26-2004 12:06 PM



Advertisments