Monkey original, reprinted. Reprinted Please note: Reprinted from cocos2d Development Network --cocos2dev.com, thank you!
Original address: http://www.cocos2dev.com /? P = 322
During online games, the server time is converted to the local time when it is locally displayed, and the system function conversion can be used.
Long long int timesec = "1353735416"; // if this is the server's time char STR [64] = {0}; time_t timep = timesec; sprintf (STR, "% s ", asctime (gmtime (& timep )));
STR is the day of the week + date + time
If you want to define your own format, use the following method.
Long long int timesec = "1353735416"; // if this is the server's time char STR [64] = {0}; time_t timep = timesec; TM * timestuct = gmtime (& timep); sprintf (STR, "% 02d/% 02d/% 02d % 02d: % 02d", timestuct-> tm_year + 1900, timestuct-> tm_mon + 1, timestuct-> tm_mday, timestuct-> tm_hour, timestuct-> tm_min );