2014-01-13 59 views

回答

2

既然你没有示例代码,您的时间戳是如(什么格式没有暗示。字符串或time.Time),你只能得到一个关于如何检查时间戳是否在想要的范围内的一般答案。

假设:使用time.Timetime

实施例:

package main 

import (
    "fmt" 
    "time" 
) 

func main() { 
    t := time.Now() 

    if t.Hour() < 8 { 
     fmt.Println("Time is between 12AM - 8AM (not including 08:00)") 
    } else { 
     fmt.Println("Time is not within the span") 
    } 
} 
相关问题