[Country EMBED strategy] [077] [Linux time programming]

Source: Internet
Author: User

Time Type

Coordinated Universal time (UTC): world standard times, i.e. GMT (Greenwich Mean, GMT).

Calendar time: The time that is represented by a standard point in time (January 1, 1970 0 o'clock) to the number of seconds elapsed.

#include <stdio.h>#include<time.h>#include<sys/time.h>voidMain () {//Get calendar Timetime_t CTime; Time (&CTime); printf ("CTime is%d\n", CTime); //Get microsecond time    structTimeval Mtime; Gettimeofday (&Mtime, NULL); printf ("Mtime is%d.%d\n", Mtime.tv_sec, mtime.tv_usec); //Get Standard Time    structTM *Gtime; Gtime= Gmtime (&CTime); printf ("Gtime is%02d:%02d\n", Gtime->tm_hour, gtime->tm_min); //Get local time    structTM *Ltime; Ltime= LocalTime (&CTime); printf ("Ltime is%02d:%02d\n", Ltime->tm_hour, ltime->tm_min); //Convert time Format    Char*Atime; Atime=asctime (ltime); printf ("Atime is%s\n", atime);}

[Country EMBED strategy] [077] [Linux time programming]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.