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

后端 未结 8 1222
礼貌的吻别
礼貌的吻别 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 05:05

    You can use now library, it really simple :

    now.BeginningOfMonth()    // 2013-11-01 00:00:00 Fri
    now.EndOfMonth()          // 2013-11-30 23:59:59.999999999 Sat
    

    Please take a look here for detail : https://github.com/jinzhu/now

提交回复
热议问题