473,387 Members | 1,890 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Setting Time in C

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
Nov 13 '05 #1
6 8116
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??


Nov 13 '05 #2
Thanks for the information. ^_^

--
Regards

Jimmy Lim

"Pushkar Pradhan" <pu*****@gri.msstate.edu> wrote in message
news:3F**************@gri.msstate.edu...
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??

Nov 13 '05 #3

"Pushkar Pradhan" <pu*****@gri.msstate.edu> wrote in message
news:3F**************@gri.msstate.edu...
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
Nov 13 '05 #4

"Jimmy" <ji*****@iwow.com.sg> wrote in message
news:bl**********@mawar.singnet.com.sg...
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
Nov 13 '05 #5
Thanks

--
Regards

Jimmy Lim

"Mike Wahler" <mk******@mkwahler.net> wrote in message
news:aQ************@newsread3.news.pas.earthlink.n et...

"Jimmy" <ji*****@iwow.com.sg> wrote in message
news:bl**********@mawar.singnet.com.sg...
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

Nov 13 '05 #6
In <bl**********@mawar.singnet.com.sg> "Jimmy" <ji*****@iwow.com.sg> 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: Da*****@ifh.de
Nov 13 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: mydejamail | last post by:
Coming from an objectpascal background with strict type checking, I am being driven nuts by PHP. Stuff like using variables without declaring them, case sensitivity of variables, getting true,...
18
by: Dixie | last post by:
Can I set the Format property in a date/time field in code? Can I set the Input Mask in a date/time field in code? Can I set the Format of a Yes/No field to Checkbox in code? I am working on...
8
by: David Lozzi | last post by:
Howdy, I have a user control that is a report to display data. On the page the control is inserted in, I have filter options to filter the report. When I try to do something like this, nothing...
3
by: cleo | last post by:
In VB6 my practice was to set control properties at Run Time rather than Design Time. I found setting property values in the code provided better documentation, since much of this was hidden - and...
2
by: Ken Varn | last post by:
I have a managed C++ method that I call from ASP.NET to set the time zone on the local box. I call SetTimeZoneInformation, which does not return an error, but the time zone remains unchanged. I...
10
by: MLH | last post by:
I was wondering if setting object vars to Nothing near the end of a sub procedure was beneficial at all - since they (the OV's) are about to go out-a-scope anyway? For example, Sub MySub()...
1
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 on Apache 2 on Fedora Core 5. PHP was installed using Apache's apxs and the php library was installed to /usr/local/php. However, when I set my "error_reporting"...
7
by: Ronald S. Cook | last post by:
In a .NET Windows app, if I set somehting like the title of the form to "MyApp" at run-time, will that make the app run slightly slower than if I had set the title at design-time? Thanks, Ron
7
by: PetterL | last post by:
I have a setting called My.settings.firstrun set to True, set in the setting manager. When i read this in the first form form_Load in a IF sentence it always come out as false. I have tried to...
5
by: =?Utf-8?B?bWFzaXg=?= | last post by:
We have an issue with load time in several installations of our application. We've located the information regarding KB 936707 and ensured that the application config file contains the runtime...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.