2014-01-13 64 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") 
    } 
} 
相關問題