I am doing a program in #C for the university and I need to get the current system date to know when the person has registered.
So far to catch the date I have this:
time_t tiempo = time(NULL);//variables donde guardo el valor de la funcion time. struct tm *tlocal = localtime(&tiempo); //estructura donde obtengo el tiempo char output; //array donde guardo la fecha strftime(output,10,"%d/%m/%y",tlocal); //formato para guardar la fecha obtenido en *tlocal como dd/mm/yyyy printf("%s\n",output);
The problem is that in doing this the date is saved correctly but the year only has 2 digits, that is, instead of saving 10/04/2017 it saves 10/04/17.
I have searched the internet to save the complete date with all the digits and I have read that if in the function
strftime I put the
y in uppercase it keeps the 4 digits of the year but I have tried it and it does not work for me.
Any ideas to get the system date in dd / mm / yyyy format?