473,670 Members | 2,499 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(&curr entTime );

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 7411
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
6137
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 all times on the 24 hour clock?
14
2488
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 structure such as day of the week or day of the year, but I do know year,month,date,hour,min,sec. Does the language support filling in the missing elements. And is there a consistency check for that time structure.
5
35666
by: francescomoi | last post by:
I'm trying to show current Unix time in C. Is it possible?
7
7043
by: Drunkalot | last post by:
How can I set the system time using a DateTime object??? s...
5
2903
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
2055
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 (Record Source: ItemName) This form also contains three textboxes and and
1
1657
by: John | last post by:
Hi How can I subtract 10 minutes from a date/time value? Thanks Regards
0
3275
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 - see *** in code snippet below) which processes a large csv file into smaller csv files based on time (GMT, UTC). myprog.c was run on MAC OSX and but won't compile for me. Probably these two functions were defined in the time.h that was used. But...
2
1508
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 get back out that which I put in? The times concerned are all standard
0
8386
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8591
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,...
0
7415
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6213
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
5683
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
4209
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
4390
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2041
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1792
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.