Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

timegm(3) [redhat man page]

TIMEGM(3)						     Linux Programmer's Manual							 TIMEGM(3)

NAME
timegm, timelocal - inverses for gmtime and localtime SYNOPSIS
#include <time.h> time_t timelocal (struct tm *tm); time_t timegm (struct tm *tm); DESCRIPTION
The functions timelocal() and timegm() are the inverses to localtime(3) and gmtime(3). NOTES
These functions are GNU extensions. The timelocal() function is equivalent to the POSIX standard function mktime(3). There is no reason to ever use it. For a portable version of timegm(), set the TZ environment variable to UTC, call mktime() and restore the value of TZ. Something like #include <time.h> #include <stdlib.h> time_t my_timegm (struct tm *tm) { time_t ret; char *tz; tz = getenv("TZ"); setenv("TZ", "", 1); tzset(); ret = mktime(tm); if (tz) setenv("TZ", tz, 1); else unsetenv("TZ"); tzset(); return ret; } SEE ALSO
gmtime(3), localtime(3), mktime(3), tzset(3) GNU
2001-12-26 TIMEGM(3)

Check Out this Related Man Page

TIMEGM(3)						     Linux Programmer's Manual							 TIMEGM(3)

NAME
timegm, timelocal - inverses for gmtime and localtime SYNOPSIS
#include <time.h> time_t timelocal (struct tm *tm); time_t timegm (struct tm *tm); DESCRIPTION
The functions timelocal() and timegm() are the inverses to localtime(3) and gmtime(3). NOTES
These functions are GNU extensions. The timelocal() function is equivalent to the POSIX standard function mktime(3). There is no reason to ever use it. For a portable version of timegm(), set the TZ environment variable to UTC, call mktime() and restore the value of TZ. Something like #include <time.h> #include <stdlib.h> time_t my_timegm (struct tm *tm) { time_t ret; char *tz; tz = getenv("TZ"); setenv("TZ", "", 1); tzset(); ret = mktime(tm); if (tz) setenv("TZ", tz, 1); else unsetenv("TZ"); tzset(); return ret; } SEE ALSO
gmtime(3), localtime(3), mktime(3), tzset(3) GNU
2001-12-26 TIMEGM(3)
Man Page

4 More Discussions You Might Find Interesting

1. Programming

may be simple but i don't know -- Print current date from C program

How to print current date of the Unix system accessing thru C++ program ? I wrote like this #include <time.h> ....... time_t tt; struct tm *tod; .... time(&tt); tod = localtime(&tt); cout << tod->tm_mon + 1 << "/" << tod->tm_mday << "/" ... (6 Replies)
Discussion started by: ls1429
6 Replies

2. Programming

Conversion of time structure in C++

Hi frnds, I have written a code to get current time struct tm *locTime; time_t currentTime; time( &currentTime ); locTime = localtime(&currentTime ); Suppose now i get output time as 31-DEC-2007 00:00:00 What i want now is i want two strings where in one string i want to subtract... (1 Reply)
Discussion started by: electroon
1 Replies

3. Shell Programming and Scripting

Compute in milisecond by use of mktime

Hi, I want to calculate diff b/w these starttime and endtime with use of mktime. I need response time in milisecond. I am using mktime to get these times. last three digits are in milisecond Starttime 2013-04-03 08:54:19,989 End time 2013-04-03 08:54:39,389 (9 Replies)
Discussion started by: random_thoughts
9 Replies

4. Shell Programming and Scripting

Diff between two time in hours in last column

Dear All I want to diff between two time(FIRST 4 COLUMN) in hours in last column. Kindly help me for same. 2013-11-23 15:51:23 2013-11-23 12:20:06 BRC023 CG 2013-11-23 15:51:23 2013-11-23 12:20:08 BRC064CG 2013-11-23 15:51:23 2013-11-22 13:17:49 BLM003 NG 2013-11-23 15:51:23 2013-11-22... (9 Replies)
Discussion started by: jaydeep_sadaria
9 Replies