• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 248
  • Last Modified:

Correct TZ Time

I have a program that saves the time as GMT instead of the current timezone on a UNIX box. How do I modify this snippit to produce the correct time zone time?

(part of an fprintf statement)

c=mygethostbyaddr((char*)&trans->data.trans.client.s_addr),timestamp->tm_mday,monthname[timestamp->tm_mon],timestamp->tm_year+1900,timestamp->tm_hour,timestamp->tm_min,timestamp->tm_sec;

Thanks,
Brian

0
bruth
Asked:
bruth
1 Solution
 
xLsCommented:
pasted from msdnlibrary:

Converts a time value and corrects for the local time zone.

struct tm *localtime( const time_t *timer );

or without correction of time zone

Converts a time value to a structure.

struct tm *gmtime( const time_t *timer );


hope this would help.

0
 
bruthAuthor Commented:
I had a previous line referencing gmtime and I changed it to localtime as you suggested. Solved the issue perfectly.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now