Jump to content
Sign in to follow this  
Doxie

C++ Question

Recommended Posts

Doxie

I got this question from a friend, anyone able to help?

I have 2 time values stored in tm structure. I need to know how many seconds are between. The only function for that seems to be difftime but it works with time_b values. Am i missing anything or is there really no library function that subtracts 2 values in tm format?

I got no idea :idiot:


Were ever i lay my script is my home...

Share this post


Link to post
Share on other sites
SumTingWong

I got this question from a friend, anyone able to help?

I got no idea :idiot:

<{POST_SNAPBACK}>

Use mktime to convert your tm structs to time_t values and then difftime to calculate the difference.

mktime on MSDN

Use gmtime or localtime to convert time_t value back to tm struct

Edited by pacman

Share this post


Link to post
Share on other sites
Doxie

His answer :idiot:

I know - I went through this some time ago already. This limits me to years between 1970 and somewhere around 2040.


Were ever i lay my script is my home...

Share this post


Link to post
Share on other sites
SumTingWong

His answer :idiot:

I know - I went through this some time ago already. This limits me to years between 1970 and somewhere around 2040.

<{POST_SNAPBACK}>

Why did he ask for a way to subtract between 2 tm values?

If you want to go back further, use SYSTEMTIME which starts from January 1, 1601.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.