Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
6 years, 11 months ago.
How to create a file which title is the date of the day?
Hi guys! I have a problem with file name of micro sd. I want that the name of the file created in a directory of a micro sd, is the date of the day (ex.12/21/2017). I have this function to get date and time:
code[ void SetDateTime(int year=2017, int mon=0, int day=1, int hour=0,int min=0,int sec=0) { struct tm Clock; Clock.tm_year = year - 1900; Clock.tm_mon = mon; Clock.tm_mday = day; Clock.tm_hour = hour; Clock.tm_min = min; Clock.tm_sec = sec; time_t epoch = mktime(&Clock); if (epoch == (time_t) -1) { error("Error in clock setting\n"); Stop here } set_time(epoch); } ] I obtained time in the main function, but i can't obtain the date of the day in fopen(). How could I do?