- now = time(NULL);
- strftime(timestr, sizeof timestr, "%Y-%m-%d %H:%M:%S", localtime(&now));
+ if(!now.tv_sec)
+ gettimeofday(&now, NULL);
+ time_t now_sec = now.tv_sec;
+ strftime(timestr, sizeof timestr, "%Y-%m-%d %H:%M:%S", localtime(&now_sec));