cocos2d-x 时间

long long int timeSec = 1353735416;//假如这是服务器的时间

    char str[64] = {0};

    time_t timep = timeSec;

    sprintf(str, "%s",asctime(gmtime(&timep)));



打印出 Sat Nov 24 05:36:56 2012

相当与 OC中的 NSData

需要转成 NSData 格式的时间

   tm* timeStuct = gmtime(&timep);

   sprintf(str, "d/d/d d:d",

   timeStuct->tm_year + 1900,

   timeStuct->tm_mon + 1,

  timeStuct->tm_mday,

   timeStuct->tm_hour,

   timeStuct->tm_min);

   printf(str);

 

你可能感兴趣的:(cocos2d-x)