Hi im trying to store the current date and time to a file. When i print it, it is in the US format - MM/DD/YYYY

#include <time.h>

_strdate( dateStr );
cout << "Current date: " << dateStr << endl;
_strtime( timeStr );
cout << "Current time: " << timeStr;

Output:
Current date: 09/17/10
Current time: 14:20:55

I want 17/09/10, is there a way to do this? Without using a delimtter and printing the day, month, year seperatly.

use strftime() and you can format the date any way you want. All you need is a struct tm object. And you can get that from either localtime() or mktime()

use strftime() and you can format the date any way you want. All you need is a struct tm object. And you can get that from either localtime() or mktime()

Hi, can you give me an example of how to use the strftime()?
I'm not sure what all parameters are for, as i only want to print the date and time. If i omit them it gives me an error.

cheers

That link already contains example code. If you don't understand it then write your own little program and play around with the format string to see what they do.