zoukankan      html  css  js  c++  java
  • C库得到系统当前的时间

    #include <stdio.h>
    #include <stdlib.h>
    #include <time.h>
    
    
    static time_t  end_time;
    
    
    int main()
    {
    
    #if 0
    struct tm
    {
        int    tm_sec;        /* Seconds: 0-59 (K&R says 0-61?) */
        int    tm_min;        /* Minutes: 0-59 */
        int    tm_hour;    /* Hours since midnight: 0-23 */
        int    tm_mday;    /* Day of the month: 1-31 */
        int    tm_mon;        /* Months *since* january: 0-11 */
        int    tm_year;    /* Years since 1900 */
        int    tm_wday;    /* Days since Sunday (0-6) */
        int    tm_yday;    /* Days since Jan. 1: 0-365 */
        int    tm_isdst;    /* +1 Daylight Savings Time, 0 No DST,
                     * -1 don't know */
    };
    #endif
    
        time(&end_time);//得到当前从1970开始的时间
        //_CRTIMP struct tm*  __cdecl __MINGW_NOTHROW    localtime (const time_t*);
        struct tm*   current_tm = localtime(&end_time); // 这个参数不能传空的
        printf("11111current_tm is %p
    ",current_tm);//
        if(current_tm == NULL)
        {
            printf("Create current_tm error
    ");
        }
        printf("tm_year  is %d
    ",current_tm->tm_year+1900);
        printf("tm_mont is %d
    ",current_tm->tm_mon+1);
        printf("tm_day is %d
    ",current_tm->tm_mday);
        printf("tm_mount is %d
    ",current_tm->tm_hour);
        printf("tm_分钟 is %d
    ",current_tm->tm_min);
        printf("tm_second is %d
    ",current_tm->tm_sec);
        printf("tm 星期几 is %d
    ",current_tm->tm_wday);
        printf("365中第几天了 is %d
    ",current_tm->tm_yday);
        printf("哪个时区 is %d
    ",current_tm->tm_isdst);
        printf("ctime is %s
    ",ctime(&end_time));//produce an Invalid Page
     //* Fault and crap out your program. 参数不能传空
     
        end_time = 100000000;
        current_tm = gmtime(&end_time);
        printf("tm_year  is %d
    ",current_tm->tm_year+1900);
        printf("tm_mont is %d
    ",current_tm->tm_mon+1);
        printf("tm_day is %d
    ",current_tm->tm_mday);
        printf("tm_mount is %d
    ",current_tm->tm_hour);
        printf("tm_分钟 is %d
    ",current_tm->tm_min);
        printf("tm_second is %d
    ",current_tm->tm_sec);
        printf("tm 星期几 is %d
    ",current_tm->tm_wday);
        printf("365中第几天了 is %d
    ",current_tm->tm_yday);
        printf("哪个时区 is %d
    ",current_tm->tm_isdst);
    
        while(1);
        return 0;
    }

    一勤天下无难事。
  • 相关阅读:
    读书笔记 ASP.NET 2.0编程珠玑
    为什么公司招聘一个好员工很难,程序员找份好工作也不容易
    读书笔记 ASP.NET 2.0高级编程 第31章 配置
    Win7 x64 旗舰版下重新注册IIS7.5
    T_SQL 开发的13个Tips
    报表服务扩展:基于WCF技术的报表服务扩展
    实现多国语言的Reporting Services项目
    技术人生:如何成为一位优秀的程序员
    幸福框架:待实现的基础应用列表
    技术人生:做人十心机
  • 原文地址:https://www.cnblogs.com/nowroot/p/13549410.html
Copyright © 2011-2022 走看看