• C++调用API获取当前时间


    #include <string> 
    #include<iostream>
    #include<windows.h>
    #include <sstream>
    using namespace std;
    
    string WORDToString(WORD w)
    {
        char tmpbuff[16];
        sprintf(tmpbuff,"%d",w);
        string res=tmpbuff;
        return res;
    }
    string getTime()
    {
        string week[7]={"星期日","星期一","星期二","星期三","星期四","星期五","星期六"};
        SYSTEMTIME now;   
        string currentTime;  
        GetLocalTime( &now );   
        currentTime=WORDToString(now.wYear)+""  
            +WORDToString(now.wMonth)+""  
            +WORDToString(now.wDay)+"" 
            +"("+week[now.wDayOfWeek]+") "
            +WORDToString(now.wHour)+":"  
            +WORDToString(now.wMinute)+":"  
            +WORDToString(now.wSecond)+" "  
            +WORDToString(now.wMilliseconds)+"ms";  
        return currentTime;
    }
    int main() 
    { 
        cout<<getTime()<<endl;
        return 0;
    }
  • 相关阅读:
    同舟共济
    MQTT客户端
    Emgucv安装及使用
    Go生成UUID
    Go语言使用百度翻译api
    Go压缩文件
    Go语言的标准net库使用
    Go文件操作
    Go语言获取本地IP地址
    禅道使用规范
  • 原文地址:https://www.cnblogs.com/LyShark/p/9158588.html
Copyright © 2020-2023  润新知