#include <stdio.h>
#include <time.h>
#include <string>
using namespace std;
//#pragma warning(disable : 4996) //_CRT_SECURE_NO_WARNINGS
int main() {
time_t NowTime;
time(&NowTime);
struct tm* timeInfo = localtime(&NowTime);
char timeStr[32];
strftime(timeStr, sizeof(timeStr), "%Y-%m-%d", timeInfo);
printf("%s", timeStr);
}
執行結果:
2017-10-31
strftime函數
http://www.cplusplus.com/reference/ctime/strftime/
沒有留言:
張貼留言