473,782 Members | 2,436 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Time and date

Hello all,
I am using Turbo c 2.1.
I have reqritten the timer interrupt in PC as per my requirement.Whe n
I use gettime() and getdate()
in my program leter I am not getting current time and date.How to get
the Time and Date directly from the CMOS.
Thanks in advance.
Ram

May 31 '07 #1
3 3544
raam wrote:
Hello all,
I am using Turbo c 2.1.
I have reqritten the timer interrupt in PC as per my requirement.Whe n
I use gettime() and getdate()
in my program leter I am not getting current time and date.How to get
the Time and Date directly from the CMOS.
Thanks in advance.
In the C programming language as it is defined, there is no such thing
as "CMOS". Nor are there such things as gettime() or getdate().

You get the current time and date with functions declared in <time.h>.
In particular, you can get the current calendar time with (surprise!)
the function time(), which returns a variable of type time_t. If all
you want is a string representing the current time and date, you can use
ctime() with the value from time() which returns a pointer to a string.

Here is an example:

#include <stdio.h>
#include <time.h>
int main(void)
{
time_t t;
struct tm tstruct;
t = time(0);
tstruct = *localtime(&t);
printf("The time from ctime is %s", ctime(&t));
printf("The time from asctime is %s", asctime(&tstruc t));
tstruct.tm_min += 6;
t = mktime(&tstruct );
printf("In 6 minutes,\n");
printf("The time from ctime will be %s", ctime(&t));
printf("The time from asctime will be %s", asctime(&tstruc t));
return 0;
}

[output]
The time from ctime is Thu May 31 04:52:06 2007
The time from asctime is Thu May 31 04:52:06 2007
In 6 minutes,
The time from ctime will be Thu May 31 04:58:06 2007
The time from asctime will be Thu May 31 04:58:06 2007
If you insist on using implementation-specific (and particular
hardware-specific) things like timer interrupts, CMOS, gettime(), and
getdate(), then you are not writing code that can be used in any other
environment, In fact, many of us will not be able to even compile that
code. Such code is _off-topic_ in <news:comp.lang .c>. You need to
check your documentation and, if you have problems, check a newsgroup or
mailing list for your 20-year-old compiler and its non-standard
functionality, if you can find it.

May 31 '07 #2
On 31 Mai, 07:30, raam <muthuramantrip ...@gmail.comwr ote:
Hello all,
I am using Turbo c 2.1.
We don't do specific compilers here.
I have reqritten the timer interrupt in PC as per my requirement.Whe n
We don't do timer interrupts here.
I use gettime() and getdate()
in my program leter I am not getting current time and date.
We don't support non-standard C functions.
How to get the Time and Date directly from the CMOS.
We don't access CMOS here.

Short answer:
Easy on DOS, more difficult on a modern Windows box.

Check the IBM-PC spec on CMOS, depending on which OS you use, the "C
code" will vary, except beeing off-topic here.

The best place to ask, might be in an assembler programming group
(they can do C snippets as well).

--
Tor

May 31 '07 #3
Tor Rustad wrote:
On 31 Mai, 07:30, raam <muthuramantrip ...@gmail.comwr ote:
>Hello all,
I am using Turbo c 2.1.

We don't do specific compilers here.
Okay, but he is just giving you some background information, some
context if you will.
>
> I have reqritten the timer interrupt in PC as per my requirement.Whe n

We don't do timer interrupts here.
Again, just context information. The OP was not asking how to do
interrupts.
>
>I use gettime() and getdate()
in my program leter I am not getting current time and date.

We don't support non-standard C functions.
Ditto. But you could civilly say these are non-standard.

>
>How to get the Time and Date directly from the CMOS.

We don't access CMOS here.
Try to write wearing his shoes: He knows you can get the date and time
using standard functions, but does not know how, and he knows the date
and time are stored in the CMOS of his computer. He was asking a simple
direct question, but not the way you wanted to be asked.
Short answer:
Easy on DOS, more difficult on a modern Windows box.

Check the IBM-PC spec on CMOS, depending on which OS you use, the "C
code" will vary, except beeing off-topic here.

The best place to ask, might be in an assembler programming group
(they can do C snippets as well).
This was more helpful. My answer would be to explore the functions in
<time.h>. Specifically, the types time_t, the functions time() and
localtime(), and possibly ctime()
--
Tor

--
Regards,
Stan Milam
=============== =============== =============== =============== =
Charter Member of The Society for Mediocre Guitar Playing on
Expensive Instruments, Ltd.
=============== =============== =============== =============== =
Jun 3 '07 #4

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

Similar topics

1
7149
by: Shaiboy_UK | last post by:
Hi All, Sorry if this is the wrong newsgroup to post into, on this topic, if so, please point me in the right direction..... Currently working on a ASP for a friend, which requires the date and time on it. It pulls in entries from an Access Database with dates and times in the format of: "Fri Oct 17 18:02:46 2003" However my date and time on the ASP page is displayed as:
3
3400
by: Roel Castro | last post by:
Hello everyone, Could somebody help me how to open time/date item in Control panel by codes in access form modules? Taking in consideration the operating system which is Windows 98, Windows 2000 and windows XP.
4
2645
by: qtip | last post by:
I have a simple table the has First Name , Last Name, SSN, Date&Time. I have a report that will show all this information but I would like to put in at calculation to tell the difference between 2 Date&time stamps for the person. The report shows Last name, First Name and Date&Tiem Field. If the persone has 2 records I would like to show the amount of time between each in put.
9
3229
by: Bob Achgill | last post by:
I would like to use the timestamp on files to manage the currency of support files for my VB windows application. In this case I would only put the timestamp of the file in the management database and not the file itself. To do this I will need to have a File class property for Create time and date that will let me "set" the Create time and date of the file to my own chooseing. The VB file class does not appear to have the ability
8
4557
by: bessie | last post by:
I have a registration form that loads into a dava.csv file (code below). I want to add a time/date stamp so that each time someone registers, the last column in the spreadsheet shows the time/date. I've tried several things but all have failed and the form stops working. I'm taking classes this fall on programming but need to do this now, unfortunately. Any help? :confused: <?php @extract($ POST); if(is_writable('data.csv')) { $fp =...
9
3033
by: Jackson1 | last post by:
I am new to access and have created a database. I have created a couple of fields Date/ Time of Call Date and Time of placement Date and time of procedure I need to calculate the differance between Date and time of initial call Differance between Date / Time of placement Differance between Date/ Time of procedure. Times are in 2:30:00 PM and 14: 30 formats.
1
1551
by: tulikapuri | last post by:
Friends , i want to chart the data from report for on daily, weekly and monthly basis and i have three variable i.e. time , date and Moisture. Can someone guide me how to arroach this issue, its simply driving me nuts.
3
2298
by: climber | last post by:
Hello, I am attemping to append a memo box or text box with a time/date stamp. What I would like to happen is either when I click a button the time/date stamp prints below what is already typed into the text box or it prints automatically below the entered text when I click on the text box in order to make changes to the text box Ex. Hello how are you! 6/5/07 1:15:00 I am fine!
12
5568
by: skyy | last post by:
Hi.. I am working on Arm-linux os on developement board. The OS reset the time and date whenever the board is reset. Is there any way that i can run a script to set the time/date instead of manually setting it? Thanks..
1
1351
by: thesti | last post by:
hi, i'm new to php. how to show the time / date, a message is posted. like in forums, there are something like, "5 minutes ago", "8 hourse 17 minutes ago", "Yesterdar", "10-07-2008". in every post. thanks
0
10313
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10146
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10080
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7494
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6735
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5378
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3643
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2875
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.