LocalTime Time Acquisition

Source: Internet
Author: User

In the Linux environment, the application needs to record the data statistics of the KPI, get the time function in the code, LocalTime (), asctime view, get the event for the East eight area time, consistent with the current system time, and remote SSH from another server to start this application, get the time of UTC, is not converted to the East eight area time;

# ssh 10.118.203.140 "/time"
root@10.118.203.140 ' s Password:
Asctime (now) is Mon Dec 18 00:43:25 2017
#./time
Asctime (now) is Mon Dec 18 13:43:34 2017


code example:

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

using namespace Std;
Using Std::string;

int main ()
{
time_t t=time (NULL);
struct TM *now;
now = LocalTime (&t);
cout << "Asctime (now) are" << asctime (now) << Endl;
return 0;
}


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.