• C

Difference between struct tm and time_t

Please, explain the real difference between struct tm and time_t.
Need more deep understanding.
Also, it's good to provide functions which works with each of this data type.
Nusrat NuriyevAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

plusone3055Commented:
time_t  = should be used internally

struct tm =  externally
0
Nusrat NuriyevAuthor Commented:
plusone3055,
could you provide a bit more concrete answer?
The concrete question is: what does mean internally or externally? Internally or externally to what?
0
plusone3055Commented:
time for internal storage TM for an external display
0
Nusrat NuriyevAuthor Commented:
okay, how to convert them to each other? Is there any pitfals related with conversion, like, when you convert strings in windows?
0
ozoCommented:
time_t mktime(struct tm *tm);

struct tm *localtime(const time_t *timep);
struct tm *gmtime(const time_t *timep);

localtime and gmtime return a pointer to static data  and  hence  are  not  thread-safe.   Thread-safe  versions gmtime_r() and localtime_r() are specified by SUSv2, and available since libc 5.2.5.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C

From novice to tech pro — start learning today.