ios获取当前时间格式
const char * getTimeFormat(int intTime)
{
// 参数intTime表示函数获取的是这一时刻的时间,如果函数只是获取当前时间,那么可以直接写time_t timep = time(NULL);
time_t timep = intTime;
// localtime表示本地时间,如果要用UTC时间,则要用gmtime函数代替
tm * timeStuct = localtime(&timep);
CCString * timeCStr;
timeCStr = CCString::createWithFormat("%04d-%02d-%02d %02d:%02d:%02d",
timeStuct->tm_year + 1900, timeStuct->tm_mon + 1, timeStuct->tm_mday,
timeStuct->tm_hour, timeStuct->tm_min, timeStuct->tm_sec);
return timeCStr->getCString();
}