473,513 Members | 2,752 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Subtracting time from tm structure

8 New Member
Hi frnds,

I have written a code to get current time

struct tm *locTime;
time_t currentTime;
time( &currentTime );
locTime = localtime(&currentTime );

Suppose now i get output time as 31-DEC-2007 00:00:00

What i want now is i want two strings where in one string i want to subtract time to 2 hours that is one string should have value as 30-DEC-2007 22:00:00 and other string should have value 26 hours less that is 23-DEC-2007 22:00:00

I tried some cases where in i subtracted value but it was not working.Is there a way out for this
Jan 5 '08 #1
1 7378
weaknessforcats
9,208 Recognized Expert Moderator Expert
I don't use this time very often but I think you subtract from the time_t rather than from the struct tm.

That means you keep your times in time_t variables and use library functions to create and display the time_t variables.

The struct tm is statically allocated so all time functions use the same struct tm.
Jan 5 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
6126
by: Robert Schoenert | last post by:
I want to be able to subtract two time fields, one starting before midnight and the other past midnight. example: starttime 23:00 and endtime 01:10 The answer is 1:10. How can I do this with...
14
2478
by: George | last post by:
In Time.h there is a structure defined for time settings. I'm building an embedded system that has a Real Time Clock but it's not PC compatible. My question is: I don't some elements of the...
5
35645
by: francescomoi | last post by:
I'm trying to show current Unix time in C. Is it possible?
7
7034
by: Drunkalot | last post by:
How can I set the system time using a DateTime object??? s...
5
2895
by: Summu82 | last post by:
HI I have to convert a time in the format i have year month day hour min and seconds I need to convert this into time in seconds since 1 jan 1970 i.e the
1
2050
by: Drum2001 | last post by:
I have a table that contains the following fields: ItemName // Name of Assignment AvgTime //Estimated number of mins to complete I have a form that has a combo box listing all assignments...
1
1646
by: John | last post by:
Hi How can I subtract 10 minutes from a date/time value? Thanks Regards
0
3253
hqprog
by: hqprog | last post by:
Having search extensively I've learned the two functions timegm and gmtime_r though in the GNU standard C library extend the ISO standard. I need to use these two functions in myprog.c (on pc - ...
2
1489
by: Joshua J. Kugler | last post by:
I am getting results like these with the time module: %S'))) 1173610800 %S'))) 1173610800 '2007-03-11 03:00:00' I know it probably has something to do with daylight savings, but how can I...
0
7254
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7153
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
7094
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...
0
7519
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5079
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...
0
4743
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...
0
3230
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...
0
3218
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1585
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.