Home C-tutorials C GMT Time



C GMT Time
Posted on: February 5, 2009 at 12:00 AM
In this section, you will study how to get the gmt time in C. GMT stands for Greenwich Mean Time.

C GMT Time

     

In this section, you will study how to get the gmt time in C. GMT stands for Greenwich Mean Time. In the given example, the time() function determines the current time in seconds and assign it to t. We have used the library function gmtime() to adjust a time_t representation to a Universal Time string, and then converts it to a printable string using the asctime() function.

Here is the code:

GMTTIME.C

#include <stdio.h>
#include <time.h>
#include <conio.h>
void main() {
  time_t t;
  time(&t);
  printf("Current Time is: %s\n", ctime(&t));
  printf("GMT Time is: %s\n", asctime(gmtime(&t)));
  getch();
}

Output will be displayed as:

Download Source Code:

Related Tags for C GMT Time:
ctimefunctionfuniogetrmithisforexamplestudyunctoexamssieilsignitsectionimcurrentinrmasstamntminminesfuncmemeanhowxawicxampstermeegmtisimellivmtmplgreeaandsecondsssrenthcondstetermetermpleplmindono


More Tutorials from this section

Ask Questions?    Discuss: C GMT Time  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.