获取指定日期时间

获取指定日期时间

#define _CRT_SECURE_NO_WARNINGS * *//一定要添加上**
#include<stdio.h>
#include<time.h>
int main()
{
time_t     now;
struct tm  ts;
char       strTimeBuf[80];
//Get current time
time(&now);
now = now – 60 * 10 * 6 * 24 * 15;//获取15天前时间
ts = *localtime(&now);
strftime(strTimeBuf, sizeof(strTimeBuf), “%Y-%m-%dT%H:%M:00”, &ts);
printf(“%s\n”, strTimeBuf);
char startTime[80] = “2022-05-09T00:00:00.000+08:00”;//前一天日期
int dayStart = 1;
int dayEnd = 3;
int MonthTemp = 1;
int YearTemp = 2022;
int DayTemp = 01;//20221026
//sprintf(startTime, “%04d-%02d-01T00:00:00.000+08:00”, systime.wYear, systime.wMonth);//dayStart
sprintf(startTime, “%s.000+08:00”, strTimeBuf);//dayStart
printf(“startTime:  %s\n”, startTime);
strftime(strTimeBuf, sizeof(strTimeBuf), “%Y-%m-%d %H:%M:00”, &ts);
printf(“获取前15天日期时间:%s\n”, strTimeBuf);
//sprintf(startTime, “%s.000+08:00”, strTimeBuf);//dayStart  //15天前时间
//std::string body = “{\n\”pageNo\”: \”” + pageNo + “\” ,\n\”pageSize\”: \”” + pageSize + “\”  ,\n\”startTime\”: \”” + startTime + “\”  ,\n\”endTime\”: \”” + endTime + “\”\n}”;
}
stevenroc@pi $ gcc getTorceThreeData.c -o getTorceThreeData
stevenroc@pi $ ./getTorceThreeData

您可能还喜欢...

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注