cocos2d-x 获取系统时间


#include <time.> 

struct cocos2d::cc_timeval now;  // 秒,毫秒

cocos2d::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;

 

注意:在CCTime::gettimeofdayCocos2d函数中CC_UNUSED_PARAM为消除编译器给出的警告。因为该函数第二个参数没用到,可能是为了扩展用的吧。


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM