time(NULL) returning different time

Posted by cornerback84 on Stack Overflow See other posts from Stack Overflow or by cornerback84
Published on 2012-10-08T15:35:57Z Indexed on 2012/10/08 15:37 UTC
Read the original article Hit count: 172

Filed under:
|

I am trying to get current time in C using time_t current_time = time(NULL). As I understand, it would return me the current time of system. I am later trying to convert it into GMT time using struct tm* gmt = gmtime(&current_time).

I print both times using ctime() and asctime() functions.

The current time on my system is GMT + 1. But gmtime() returns me the same time as current_time is. I could not understand why gmtime() is returning me same time. Any help will be appreciated.

© Stack Overflow or respective owner

Related posts about c

    Related posts about time