获取当前时间的方法

1.CTime
CTime currentTime = CTime::GetCurrentTime();
CString strYear, strMonth;
strYear.Format("%04d", currentTime.GetYear());
strMonth.Format("%04d-%02d", currentTime.GetYear(), currentTime.GetMonth());
2.time_t
time_t currentTime = time(NULL);
struct tm *local;
local=localtime(&currentTime);
CString strYear, strMonth;
strYear.Format("%04d", local->tm_year);
strMonth.Format("%04d-%02d", local->tm_year, local->int tm_mon);
再定义一个tm结构体
struct tm
{
int tm_sec;

获取当前时间的方法最先出现在Python成神之路

版权声明:
作者:主机优惠
链接:https://www.techfm.club/p/24381.html
来源:TechFM
文章版权归作者所有,未经允许请勿转载。

THE END
分享
二维码
< <上一篇
下一篇>>