win32 ios android 获取系统时间
2016-02-23 10:55
453 查看
//得到系统时间
CCString* HelloWorld::getSystemTime()
{
}
CCString* HelloWorld::getSystemTime()
{
struct tm *tm;
if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
//win32平台 time_t timep; time(&timep); tm = localtime(&timep);
else
//android、ios平台 struct cc_timeval now; CCTime::gettimeofdayCocos2d(&now, NULL); tm = localtime(&now.tv_sec);
endif
int year = tm->tm_year + 1900; int month = tm->tm_mon + 1; int day = tm->tm_mday; int hour=tm->tm_hour; int min=tm->tm_min; CCString *string=CCString::createWithFormat("%d-%d-%d %d:%d",year,month,day,hour,min); //return mktime(tm) ; //转换为秒 return string;
}
相关文章推荐
- android特殊字符
- android 之MVP模式的入门
- Android事件驱动机制--选择事件
- Android性能优化之Bitmap的内存优化
- Android--向SD卡读写数据
- android 自定义具有反弹效果的ScrollView
- Android高级控件----AdapterView与Adapter
- android源码社区和相关资料
- Android实现推送方式解决方案
- java和android的基础
- 在Android中实现推送方式的底层原理与推送的知识及相关解决方案
- Android 蓝牙的使用(待续)
- Gradle:Plugin is too old,please update to a more recent version
- <<Android源码设计模式解析与实战>>读书笔记----- Android NDK开发学习
- Android 编程下 Touch 事件的分发和消费机制
- android.view.ViewConfiguration
- android使用自定义标题时提示“you cannot combine custom titles with other  ”
- 【Android】【Other】Android一些常用命令
- 【Android】【Other】Android一些常用命令
- 【Android】【Other】Android一些常用命令