diff --git a/src/util-time.c b/src/util-time.c index 1e4237335d..7c7a362458 100644 --- a/src/util-time.c +++ b/src/util-time.c @@ -128,11 +128,11 @@ void CreateIsoTimeString (const struct timeval *ts, char *str, size_t size) time_t time = ts->tv_sec; struct tm local_tm; struct tm *t = (struct tm*)SCLocalTime(time, &local_tm); + char time_fmt[64] = { 0 }; if (likely(t != NULL)) { - snprintf(str, size, "%04d-%02d-%02dT%02d:%02d:%02d.%06u", - t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, t->tm_hour, - t->tm_min, t->tm_sec, (uint32_t) ts->tv_usec); + strftime(time_fmt, sizeof(time_fmt), "%Y-%m-%dT%H:%M:%S.%%06u%z", t); + snprintf(str, size, time_fmt, ts->tv_usec); } else { snprintf(str, size, "ts-error"); }