GMT time and Local time ? 
Author Message
 GMT time and Local time ?

Hello,

Would you please to tell me how can I get the GMT time and the Local
time ?

Best regards,
Eric

--
     _                                                  _
    / ) |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| ( \
   / /  |                                            |  \ \
 _( /_  | _          Chow Hoi Ka, Eric             _ |  _) )_
(((\ \> |/ )                                      ( \| </ /)))
(\\\\ \_/ /                                        \ \_/ ////)

  \    _/                                            \_     /
  /   / |____________________________________________| \    \
 /   /                                                   \    \



Thu, 21 Mar 2002 03:00:00 GMT  
 GMT time and Local time ?


Quote:
>Hello,

>Would you please to tell me how can I get the GMT time and the Local
>time ?

Check your documentation for gmtime() and localtime().

HTH
John
--
John Winters.  Wallingford, Oxon, England.

The Linux Emporium - a source for Linux CDs in the UK
See http://www.linuxemporium.co.uk/



Fri, 22 Mar 2002 03:00:00 GMT  
 GMT time and Local time ?


Quote:
>Hello,

>Would you please to tell me how can I get the GMT time and the Local
>time ?

Include the header file, "time.h" in your source code to access the
functions: gmtime and localtime.

What could be simpler !

A simple example follows:

#include <stdio.h>
#include <time.h>

int main(void)
{
  struct tm *gmt, *local;

  /* Get the time */
  time_t now = time(NULL);

  /* Get the Local Time and GMT Time */
  local = localtime(&now);
  gmt = gmtime(&now);

  /* Print results */
  printf("Local Time ==> %s", asctime(local));
  printf("GMT Time ==> %s", asctime(gmt));

  return 0;

Quote:
}



Fri, 22 Mar 2002 03:00:00 GMT  
 GMT time and Local time ?
Quote:
> Hello,

> Would you please to tell me how can I get the GMT time and
the Local
> time ?

You can use standard functions gmtime(), localtime().
From manual:
NAME
       asctime,  ctime,  gmtime,  localtime,  mktime  -
transform
       binary date and time to ASCII
SYNOPSIS
       #include <time.h>
       struct tm *gmtime(const time_t *timep);
       struct tm *localtime(const time_t *timep);
       extern char *tzname[2];
       long int timezone;
       extern int daylight;
DESCRIPTION
       The gmtime() function converts the calendar time timep
to
       broken-down  time representation, expressed in
Coordinated
       Universal Time (UTC).
       The localtime() function converts the calendar time
timep
       to  broken-time  representation, expressed relative to
the
       user's specified  time  zone.     The  function  sets
the
       external  variables tzname with information about the
cur-
       rent time  zone,  timezone  with  the  difference
between
       Coordinated  Universal  Time (UTC) and local standard
time
       in seconds, and daylight to a non-zero value  if
standard
       US daylight savings time rules apply.
       Broken-down time representation:
              struct tm
              {
                      int     tm_sec;         /* seconds */
                      int     tm_min;         /* minutes */
                      int     tm_hour;        /* hours */
                      int     tm_mday;        /* day of the
month */
                      int     tm_mon;         /* month */
                      int     tm_year;        /* year */
                      int     tm_wday;        /* day of the
week */
                      int     tm_yday;        /* day in the
year */
                      int     tm_isdst;       /* daylight
saving time */
              };
       The members of the tm structure are:
       tm_sec The number of seconds after the minute, normally
in
              the range 0 to 59, but can be up to 61 to allow
for
              leap seconds.
       tm_min The number of minutes after the hour, in the
range
              0 to 59.
       tm_hour
              The  number  of hours past midnight, in the range
0
              to 23.
       tm_mday
              The day of the month, in the range 1 to 31.
       tm_mon The number of months since January, in the range
0
              to 11.
       tm_year
              The number of years since 1900.
       tm_wday
              The  number of days since Sunday, in the range 0
to
              6.
       tm_yday
              The number of days since January 1, in the range
0
              to 365.
       tm_isdst
              A  flag that indicates whether daylight saving
time
              is in effect at the time described.  The  value
is
              positive if daylight saving time is in effect,
zero
              if it is not, and negative if  the  information
is
              not available.
CONFORMING TO
       SVID 3, POSIX, BSD 4.3, ISO 9899
SEE ALSO
       date(1),  gettimeofday(2), time(2), tzset(3),
difftime(3),
       strftime(3), newctime(3).

--
  This answer is courtesy of QuestionExchange.com
  http://www.questionexchange.com/showUsenetGuest.jhtml?ans_id=3822&cus...



Mon, 25 Mar 2002 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. How to convert GMT time to local time?

2. How to convert local time to gmt using a local variable time zone per process/thread

3. Convert local time to gmt time without using TimeZone Env variable

4. Q: How to convert GMT to local time?

5. GMT to local time conv

6. Converting GMT to local time

7. How to convert local time with specific time zone to UTC time in Win32 API

8. time confusion. I want time now GMT

9. Time: UCT, local time, daylight - any standards?

10. Time: UCT, local time, daylight - any standards?

11. Converting UTC time to local time

12. Time: UCT, local time, daylight - any standards?

 

 
Powered by phpBB® Forum Software