//通过时间戳得到字符串日期(年月日)
std::string VHelper::GetTimeStringByTimeStamp( time_t timeStamp )
{
timeStamp += 28800;
struct tm *pt;
pt = gmtime( &timeStamp );
char str[100];
strftime( str, sizeof( str ), "%Y-%m-%d", pt );
std::string timeStr( str );
return timeStr;
}
//通过时间戳得到字符串日期(年月日时分秒格式)
std::string VHelper::GetYMDHMSTimeStringByTimeStamp( time_t timeStamp )
{
timeStamp += 28800;
struct tm *pt;
pt = gmtime( &timeStamp );
char str[100];
strftime( str, sizeof( str ), "%Y-%m-%d %H:%M:%S", pt );
std::string timeStr( str );
return timeStr;
}
通过时间戳得到字符串的时间(时分秒)
std::string VHelper::GetHMSTimeStringByTimeStamp(time_t timeStamp)
{
timeStamp += 28800;
struct tm *pt;
pt = gmtime( &timeStamp );
char str[100];
strftime( str, sizeof( str ), "%H:%M:%S", pt );
std::string timeStr( str );
return timeStr;
}