获取的时间不对
struct timeval nowTimeval;
gettimeofday(&nowTimeval,NULL);
struct tm *tm;
time_t time_sec;
time_sec = nowTimeval.tv_sec;
tm = localtime(&time_sec);
CCLOG("hour = %d ,minitue = %d, second = %d",tm->tm_hour,tm->tm_min,tm->tm_sec);
struct timeval nowTimeval;
gettimeofday(&nowTimeval,NULL);
struct tm *tm;
time_t time_sec;
time_sec = nowTimeval.tv_sec;
tm = localtime(&time_sec);
CCLOG("hour = %d ,minitue = %d, second = %d",tm->tm_hour,tm->tm_min,tm->tm_sec);
2016-06-01
win32 平台,获取时间 struct tm *tm; time_t timep; #if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) time(&timep); #else struct cc_timeval now; CCTime::gettimeofdayCocos2d(&now, NULL); timep = now.tv_sec; #endif tm = localtime(&timep); int year = tm->tm_year + 1900; int month = tm->tm_mon + 1; int day = tm->tm_mday; int hour = tm->tm_hour; int min = tm->tm_min; int second = tm->tm_sec;
举报