- Timestamp2Time Errorf when timestamp is in millisecond.
This commit is contained in:
@@ -135,10 +135,15 @@ func Int2Str(value int) string {
|
||||
|
||||
// timestamp is in second
|
||||
func Timestamp2Str(timestamp int64) string {
|
||||
return Time2Str(time.Unix(timestamp, 0))
|
||||
return Time2Str(Timestamp2Time(timestamp))
|
||||
}
|
||||
|
||||
func Timestamp2Time(timestamp int64) time.Time {
|
||||
const normalTimestamp = 1533709322
|
||||
if timestamp > normalTimestamp*100 { // 传成毫秒了
|
||||
baseapi.SugarLogger.Errorf("Timestamp2Time wrong timestamp:%d", timestamp)
|
||||
timestamp = timestamp / 1000
|
||||
}
|
||||
return time.Unix(timestamp, 0)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user