zoukankan      html  css  js  c++  java
  • Mac/IOS/linux获取当前时间包含微秒毫秒的代码


    #include <sys/time.h>

    1
    struct UnityLocalTimeStat 2 { 3 int Year; 4 int Month; 5 int DayOfWeek; 6 int Day; 7 int Hour; 8 int Min; 9 int Sec; 10 int USec; 11 12 UnityLocalTimeStat() 13 { 14 memset(this, 0, sizeof(*this)); 15 } 16 };
     1 void UnityGetLocalSystemTime(UnityLocalTimeStat& OutTimeStat)
     2 {
     3     struct timeval Time;
     4     gettimeofday(&Time, NULL);
     5     
     6     struct tm LocalTime;
     7     localtime_r(&Time.tv_sec, &LocalTime);
     8     
     9     OutTimeStat.Year = LocalTime.tm_year + 1900;
    10     OutTimeStat.Month = LocalTime.tm_mon + 1;
    11     OutTimeStat.DayOfWeek = LocalTime.tm_wday;
    12     OutTimeStat.Day = LocalTime.tm_mday;
    13     OutTimeStat.Hour = LocalTime.tm_hour;
    14     OutTimeStat.Min = LocalTime.tm_min;
    15     OutTimeStat.Sec = LocalTime.tm_sec;
    16     OutTimeStat.USec = Time.tv_usec;
    17 }
  • 相关阅读:
    原来 是 需要的,
    传说中的 拉伸,
    date + 排序,
    两个 header,
    招财铃,负责模块,
    一个字母,
    一个词,
    vue+webpack静态资源路径引用
    Webstorm 的 Tab 键调整缩进值
    ES6常用语法
  • 原文地址:https://www.cnblogs.com/bodong/p/6025407.html
Copyright © 2011-2022 走看看