package main

import (
    "fmt"
    "reflect"
    "time"
)

func main() {
    //格式化字符串为时间
    test, _ := time.Parse("2006-01-02", "2013-11-11")
    //时间增加
    after, _ := time.ParseDuration("15m")
    fmt.Println(test)
    test = test.Add(after)
    fmt.Println(test)
    //格式化时间为字符串
    t3 := test.Format("2006-01-02 15:04:05")
    fmt.Println(t3)
    //格式化时间为字符串,只保留年月日
    t3 = test.Format("2006-01-02")
    fmt.Println(t3)
    fmt.Println(reflect.TypeOf(t3))
}

结果:

[ `run` | done: 1.786375ms ]
    2013-11-11 00:00:00 +0000 UTC
    2013-11-11 00:15:00 +0000 UTC
    2013-11-11 00:15:00
    2013-11-11
    string