Skip to content

Instantly share code, notes, and snippets.

@alwqx
Last active December 29, 2016 02:13
Show Gist options
  • Save alwqx/89bcb6959966e22882fd0cfb904704f0 to your computer and use it in GitHub Desktop.
Save alwqx/89bcb6959966e22882fd0cfb904704f0 to your computer and use it in GitHub Desktop.
用Golang计算某时刻前n秒的时间
package utils
import(
"fmt"
"time"
)
func SubIntervalTime(interval int64) string {
t0 := time.Now()
fmt.Println("t0:", t0.Format("2006-01-02 15:04:05"))
delta := t0.Unix() - interval
fmt.Println("interval:", interval)
t := time.Unix(delta, 0)
fmt.Println(t.Format("2006-01-02 15:04:05"))
return ""
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment