1 package main.net
2 import(orm
3 get
4 "fmt"class
5 "time"import
6 ) im
7 const TimeFormat = "2006-01-02 15:04:05"error
8 co
9 func main(){time
10 str:=time.Now().Add(-time.Hour*1).Format("2006-01-02 15:04:05")referer
11 fmt.Println("str:"+str)
12 t,err:=time.Parse(TimeFormat,str)
13 if(err != nil){
14 fmt.Println("error")
15 }else{
16 fmt.Println(t)
17 }
18 tlong:=t.Unix()-8*60*60
19 tnow0 := time.Now()
20 tnow := tnow0.Unix()
21 fmt.Println(tlong)
22 fmt.Println(tnow)
23 tme := (tnow-tlong)/60
24 fmt.Println(tme)
25 tsr := tnow0.Format("2006-01-02 15:04:05")
26 fmt.Println("-----------"+tsr)
27 ll :=time.Since(t)
28 fmt.Println(ll)
29 time.Sleep(time.Second*3)
30 mm := time.Now().Unix()
31 fmt.Println(mm)
32 }
----------------------------------
[root@localhost example]# go run time.go
str:2014-02-28 15:13:21
2014-02-28 15:13:21 +0000 UTC
1393571601
1393575201
60
-----------2014-02-28 16:13:21
-6h59m59.247388522s
1393575204