我曾经查过,但是那些方法都是特别的麻烦的,并且代码量也很大,也不好调用
所以我想分享下一个简便的方法
直接上代码
#include<time.h>
#include<stdio.h>
#include<iostream>
using namespace std;
int main(){
time_t t=time(0);
char tmp[64];
strftime(tmp,sizeof(tmp),"%Y.%m.%d",localtime(&t));
cout<<tmp<<endl;
return 0;
}