C++时间标准库时间time和系统时间的使用
发布时间:2020-12-16 07:48:40 所属栏目:百科 来源:网络整理
导读:今天PHP站长网 52php.cn把收集自互联网的代码分享给大家,仅供参考。 1. C++标准库中的时间需要引用time.h,可以取的本地时间或者格林威治时间,只能精确到秒 #include iostream/*包含time头文件*/#include time.husing n
以下代码由PHP站长网 52php.cn收集自互联网 现在PHP站长网小编把它分享给大家,仅供参考 1. C++标准库中的时间需要引用time.h,可以取的本地时间或者格林威治时间,只能精确到秒
#include <iostream> #include <Windows.h> int main(){ //声明变量 SYSTEMTIME sys_time; //将变量值设置为本地时间 GetLocalTime( &sys_time ); //输出时间 printf( "%4d/%02d/%02d %02d:%02d:%02d.%03d 星期%1dn",sys_time.wYear,sys_time.wMonth,sys_time.wDay,sys_time.wHour,sys_time.wMinute,sys_time.wSecond,sys_time.wMilliseconds,sys_time.wDayOfWeek); system("time"); system("pause"); return 0; } |