0
I’m using the tm header time. h structure as follows:
#include <stdio.h>
#include <time.h>
int main()
{
struct tm dt_current, dt_begin;
dt_current.tm_year = 2018;
dt_current.tm_mon = 11;
dt_current.tm_mday = 13;
dt_current.tm_hour = 9;
dt_current.tm_min = 45;
dt_current.tm_sec = 0;
printf("Data %d/%d/%d\n", dt_current.tm_mday, dt_current.tm_mon, dt_current.tm_year);
printf("Hora %d:%d\n", dt_current.tm_hour, dt_current.tm_min);
printf("-----------------\n");
printf("10 dias atras\n");
dt_begin = dt_current;
dt_begin.tm_mday = dt_begin.tm_mday - 30;
printf("Data %d/%d/%d\n", dt_begin.tm_mday, dt_begin.tm_mon, dt_begin.tm_year);
printf("Hora %d:%d\n", dt_begin.tm_hour, dt_begin.tm_min);
return 0;
}
Do you have a function that I can remove n days from date (dt_current) or need to do the treatment manually?
You have to do it manually. That’s all I wanted to know?
– Maniero
I thought of an easier way, turn datetime into days and subtract n days, then turn it back into datetime, it has some function that already does this or in the nail as well?
– fdavid
There is no type
datetime
all that be at hand.– Maniero