废话不多说先上代码
void HelloWorld::update(float dt){
Size visibleSize = Director::getInstance()->getVisibleSize();
struct timeval now;
__String* newTime = __String::createWithFormat("%d", now.tv_sec);
auto timettf = Label::createWithTTF(newTime->getCString(), “fonts/hanyi.ttf”, 80);
timettf->setColor(Color3B(255, 0, 0));
timettf->setPosition(visibleSize.width/2, visibleSize.height/2);
this->addChild(timettf, 20, TIMETTF);
}
运行后显示的是18670,我计算了一下大概是5个小时,然而现在时间是13:20,这串数字代表什么东西,怎么改成北京时间呢?
谢谢大神 