• 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?
 
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
 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.