Cocos2d-x中获取时间函数
来源:互联网 发布:论文表格数据来源格式 编辑:程序博客网 时间:2024/06/03 19:40
//在头文件中添加stdio.h
std::string VisibleRect::getcurrTime()//获取当前年月日{ #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS) struct timeval now; struct tm* time; gettimeofday(&now, NULL); time = localtime(&now.tv_sec); int year = time->tm_year + 1900; log("year = %d",year); char date[32] = {0}; sprintf(date, "%d-%02d-%02d",(int)time->tm_year + 1900,(int)time->tm_mon + 1,(int)time->tm_mday); log("%s",date); return StringUtils::format("%s",date); #endif #if ( CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 ) struct tm* tm; time_t timep; time(timep); tm = localtime(&timep); char date[32] = {0}; sprintf(date, "%d-%02d-%02d",(int)time->tm_year + 1900,(int)time->tm_mon + 1,(int)time->tm_mday); log("%s",date); return StringUtils::format("%s",date); #endif }
//获取今天时分秒
<pre name="code" class="cpp">std::string VisibleRect::getcurrMonthTime(){#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS) struct timeval now; struct tm* time; gettimeofday(&now, NULL); time = localtime(&now.tv_sec); int year = time->tm_year + 1900; log("year = %d",year); char date[32] = {0}; sprintf(date, "%d%02d%02d%02d%02d%02d",(int)time->tm_year + 1900,(int)time->tm_mon + 1,(int)time->tm_mday,time->tm_hour,time->tm_min,time->tm_sec); log("%s",date); return StringUtils::format("%s",date); #endif #if ( CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 ) struct tm* tm; time_t timep; time(timep); tm = localtime(&timep); char date[32] = {0}; sprintf(date, "%d-%02d-%02d",(int)time->tm_year + 1900,(int)time->tm_mon + 1,(int)time->tm_mday); log("%s",date); return StringUtils::format("%s",date); #endif}
0 0
- Cocos2d-x中获取时间函数
- Cocos2d-x中获取系统时间
- 基于cocos2d-x 3.2 的时间获取函数
- Cocos2d-x 获取系统时间
- cocos2d-x获取系统时间
- cocos2d-x获取系统时间
- cocos2d-x 获取当前时间
- cocos2d-x获取系统时间
- cocos2d-x获取系统时间
- cocos2d-x获取系统时间
- cocos2d-x 获取当前时间
- cocos2d-x获取系统时间
- cocos2d-x获取当前系统时间cocos2d-x
- Cocos2d-x 获取系统毫秒时间
- cocos2d-x获取系统时间 CCTime::gettimeofdayCocos2d
- cocos2d-x 系统时间获取和格式化
- cocos2d-x3.x 获取系统时间
- cocos2d-x获取系统日期或时间
- block_块语法
- 精通安卓性能优化-第八章(三)
- Unable to execute dex: java.nio.BufferOverflowException. Check the Eclipse log for stack trace.
- 结构体大小求值
- Heritrix 的优化
- Cocos2d-x中获取时间函数
- UVa11970 - Lucky Numbers
- hdu1285确定比赛名次(字典序最小的拓扑排序)
- C/C++优化
- 编译器安装
- spark学习十七 spark standaloe模式下资源的神情与释放
- NodeJs+Express4 练习Demo2——我的博客
- SOCKET通信的基本步骤
- HDU 1998 奇数阶魔方