zoukankan      html  css  js  c++  java
  • local_time

    time_t time(time_t *tloc);

    功能:获取纪元1970-01-01 00:00:00以来所经历的秒数

    参数:

    tloc:用来存储返回时间

    返回值:成功:返回秒数, 失败:-1

    -------------------------------------------------------------------------------------------------------

    struct tm *localtime(const time_t *timep);
    struct tm *localtime_r(const time_t *timep, struct tm *result);

    struct tm {
    int tm_sec; /* Seconds (0-60) */
    int tm_min; /* Minutes (0-59) */
    int tm_hour; /* Hours (0-23) */
    int tm_mday; /* Day of the month (1-31) */
    int tm_mon; /* Month (0-11) */
    int tm_year; /* Year - 1900 */
    int tm_wday; /* Day of the week (0-6, Sunday = 0) */
    int tm_yday; /* Day in the year (0-365, 1 Jan = 0) */
    int tm_isdst; /* Daylight saving time */
    };

    ---------------------------------------------------------------------------------------------------

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

    int main()
    {
    time_t stim;
    time(&stim);
    struct tm *stm, *stm2;
    stm = localtime(&stim);
    printf("%04d-%02d-%02d %02d:%02d:%02d ", stm->tm_year + 1900,
    stm->tm_mon + 1, stm->tm_mday, stm->tm_hour, stm->tm_min,
    stm->tm_sec);
    stm2 = localtime_r(&stim, stm2);
    printf("%04d-%02d-%02d %02d:%02d:%02d ", stm2->tm_year + 1900,
    stm2->tm_mon + 1, stm2->tm_mday, stm2->tm_hour, stm2->tm_min,
    stm2->tm_sec);
    return 0;
    }
    ---------------------------------------------------------------------------------------------------------

  • 相关阅读:
    ASP.NET 使用Ajax(转)
    使用Docker,很多坑(之一):在windows中使用
    .NET Core 各种学习资源
    docker-compose.yml配置文件详解(转)
    英雄无敌王国刷将脚本
    Valid format values for declare-styleable/attr tags[转]
    no Session问题,即延迟加载
    适配器模式--Adapter Pattern
    策略模式--Strategy
    装饰模式--Decorator Pattern
  • 原文地址:https://www.cnblogs.com/xpylovely/p/12053052.html
Copyright © 2011-2022 走看看