I have a variable which using time_t
data type. I want to convert this type into "YYYY-MM-DD HH:MM:SS". I just know if it's only works in localtime()
example:
char buff[20];
time_t now = time(NULL);
strftime(buff, 20, "%Y-%m-%d %H:%M:%S", localtime(&now));
any suggestion how to convert it? because I have the time which always increased every minute, not the fixed one like the localtime()
. I need this conversion for matching with datetime
type in MySQL database.