struct timeval now;
struct tm* time;
gettimeofday(&now, NULL);
time = localtime(&now.tv_sec);
char date[32] = {0};
sprintf(date,"%d%02d%02d",(int)time->tm_year + 1900,(int)time->tm_mon + 1,(int)time->tm_mday);
CCLog("%s",date);
系统毫秒数:
<span style="font-family: Arial, Helvetica, sans-serif;"><span style="white-space:pre"> </span> struct cc_timeval tv;</span>
<pre name="code" class="cpp"> CCTime::gettimeofdayCocos2d(&tv, NULL);
cout<<tv.tv_sec * 1000 + tv.tv_usec / 1000 <<endl;