zoukankan      html  css  js  c++  java
  • 获取系统时间

    #include <time.h>
    #include <sys/timeb.h>

    CTime t = CTime::GetCurrentTime();
    int nYear = t.GetYear() - 2000;
    int nMonth = t.GetMonth();
    int nDay = t.GetDay();
    int nTime = t.GetHour();
    int nMin = t.GetMinute();
    int nSec = t.GetSecond();

    CString mSecond;
    struct _timeb timebuffer;
    _ftime(&timebuffer);
    mSecond.Format(_T("%d"), timebuffer.millitm);
    int nMinSec = _ttoi(mSecond);

    // srand((int)time(0));
    // srand(1);
    //
    // int iRand = rand();
    // CString sRand;
    // sRand.Format(_T("%2d"), iRand);

    CString str;
    str.Format(_T("%2d%2d%2d%2d%2d%2d%2d"), nYear,nMonth, nDay,nTime,nMin,nSec,nMinSec);
    str.Replace(_T(' '), _T('0'));

    精确到毫秒

  • 相关阅读:
    $dp$模板
    字符串基础
    基础算法

    图论
    山中无甲子,寒尽不知年
    模板集合(持续更新)
    数学基础——同余
    9.19 考试总结
    1-5-17:菲波那契数列
  • 原文地址:https://www.cnblogs.com/xzh1993/p/5105837.html
Copyright © 2011-2022 走看看