cocos2d-x 获取系统当前时间
2015-12-23 09:27
1381 查看
原文地址:获取系统当前时间">cocos2d-x 获取系统当前时间作者:SHENGXIAAINJlong NetWorkManager::currentTimeNow()
{
struct cc_timeval
now;
CCTime::gettimeofdayCocos2d(&now,
NULL);
struct tm *tm;
tm =
localtime(&now.tv_sec);
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;
long millSecond=now.tv_sec *
1000 + now.tv_usec
/ 1000;
std::stringstream
currentTime;
currentTime<<year<<"-"<<month<<"-"<<day<<" "<<hour<<":"<<minute<<":"<<second<<"
"<<millSecond;
CCLog("currentTime is %s
",currentTime.str().c_str());
return millSecond;
}
{
struct cc_timeval
now;
CCTime::gettimeofdayCocos2d(&now,
NULL);
struct tm *tm;
tm =
localtime(&now.tv_sec);
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;
long millSecond=now.tv_sec *
1000 + now.tv_usec
/ 1000;
std::stringstream
currentTime;
currentTime<<year<<"-"<<month<<"-"<<day<<" "<<hour<<":"<<minute<<":"<<second<<"
"<<millSecond;
CCLog("currentTime is %s
",currentTime.str().c_str());
return millSecond;
}
相关文章推荐
- cocos2dx绘制实心圆
- cocos2dX 事件之触摸事件和触摸事件集合
- cocos2d ccmenulabel
- cocos2dx 3.7添加手机震动
- cocos2d ccitemimage
- cocos2d 多点触控
- cocos2d 单点触控
- cocos2d-js 学习笔记 --安装调试(2)
- Cocos2d-x程序员手册(ProgrammersGuide)v3.3 第9章:3D
- cocos2d js 创建项目
- cocos2dx win32修改鼠标指针图案
- cocospods的安装与应用
- cocos2dx - 伤害实现
- 自己动手写cocos2dx游戏引擎(八)——Node节点
- cocos2dx - 伤害实现
- 总结Cocos2d-x 3.0 中新字体标签Label
- cocos2d-x Programmers Guide v3.3 译本和阅读笔记(第8章:事件派发器)
- cocos2dx 导演,场景,层,精灵模型
- cocos2dx 帧动画(iOS)
- cocos2dx怎样设置ios和Android横屏竖屏的几种方法