Cocos2d-x中用C++获取当前系统时间,实现跨平台
来源:互联网 发布:淘宝历史价格 编辑:程序博客网 时间:2024/05/22 07:54
直接上代码吧
std::string Tools::get_date_now(){#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS)struct cc_timeval now;CCTime::gettimeofdayCocos2d(&now, NULL);struct tm *tm;time_t tp = now.tv_sec;tm = localtime(&tp);char date[32] = { 0 };sprintf(date, "%d-%02d-%02d", (int) tm->tm_year + 1900,(int) tm->tm_mon + 1, (int) tm->tm_mday);return string(date);#endif#if ( CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 )struct tm *tm; time_t timep; time(&timep); 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 minute=tm->tm_min; //int second=tm->tm_sec;char time[64] = { 0 };sprintf(time, "%d-%02d-%02d %02d:%02d:%02d", (int) tm->tm_year + 1900,(int) tm->tm_mon + 1, (int) tm->tm_mday, (int) tm->tm_hour,(int) tm->tm_min, (int) tm->tm_sec);return string(time);#endif}
0 0
- Cocos2d-x中用C++获取当前系统时间,实现跨平台
- Cocos2d-x 获取系统当前时间
- cocos2d-x 获取系统当前时间
- cocos2d-x获取当前系统时间cocos2d-x
- cocos2d-x 获取当前时间
- cocos2d-x 获取当前时间
- cocos2d-x获取当前系统时间-------------沈大海
- cocos2d-x获取当前系统时间-沈大海cocos2d-x教程17
- Cocos2d-x 获取系统时间
- cocos2d-x获取系统时间
- cocos2d-x获取系统时间
- cocos2d-x获取系统时间
- cocos2d-x获取系统时间
- cocos2d-x获取系统时间
- cocos2d-x获取系统时间
- 19.cocos2d-x获取当前时间
- cocos2d-x在win32和iOS、android下获取当前系统时间的方法
- Cocos2d-x 获取系统毫秒时间
- HashMap的工作原理
- Android SDK的安装教程
- XShell 4使用sftp上传下载文件命令
- IOS开发---菜鸟学习之路--(二十二)-近期感想以及我的IOS学习之路
- GCC执行过程简介
- Cocos2d-x中用C++获取当前系统时间,实现跨平台
- H3CNE 320题 RIPv2路由自动汇总
- ASP.NET MVC4 结合MVVM的应用初探(一)——国产大牛MVVM框架avalon应用
- 人生爱情幸福工作友谊家庭男人女人
- SurfaceView使用注意事项
- 156 - Ananagrams
- 解决问题
- VBS 封装Excel函数
- osg demo12 响应鼠标事件