Get the first and last day of current month in Go/Golang?

后端 未结 8 1232
礼貌的吻别
礼貌的吻别 2021-02-01 04:07

I\'m trying to get the first and last day of the current month. You can add days and hours but not the month, which I was thinking of subtracting one day from the next month to

8条回答
  •  囚心锁ツ
    2021-02-01 04:46

    goutils provides many useful func tools. goutils

    beginningOfTMonth:=time.TimeBeginningOfMonth(t)
    endOfTMonth:=time.TimeEndOfMonth(t)
    
    
    beginningOfTWeek:=time.TimeBeginningOfWeek(t)
    endOfTWeek:=time.TimeEndOfWeek(t)
    

提交回复
热议问题