java 时间戳转北京时间_时间戳转北京时间
生活随笔
收集整理的這篇文章主要介紹了
java 时间戳转北京时间_时间戳转北京时间
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
type表示輸出時間格式
0?????? ? 年月日時分秒
1?????? ? 年月日
2?????? ? 時分秒std::string TimestampToTimeString(time_t t, int nType)
{
t = t + 28800;//偏移八個時區
struct tm *p;
char s[32];
std::string strTime;
p = gmtime(&t);
switch (nType)
{
case 0:
{
strftime(s, 32, "%Y-%m-%d %H:%M:%S", p);
strTime = s;
}
break;
case 1:
{
strftime(s, 32, "%Y-%m-%d", p);
strTime = s;
}
break;
case 2:
{
strftime(s, 32, "%H:%M : %S", p);
strTime = s;
}
break;
default:
break;
}
return strTime;
}
總結
以上是生活随笔為你收集整理的java 时间戳转北京时间_时间戳转北京时间的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 经过八年研发,多美小壹推出六种医患服务机
- 下一篇: 英语小助手