date - Get the first and last day of current month in Go/Golang? -
i'm trying first , last day of current month. can add days , hours not month, thinking of subtracting 1 day next month last day of month. this:
package main import ( "fmt" "time" ) func main() { date := time.now() nextmonth := date.add(time.month) lastday := nextmonth.add(-time.hour * 24) fmt.println(lastday) }
you can use now library, simple :
now.beginningofmonth() // 2013-11-01 00:00:00 fri now.endofmonth() // 2013-11-30 23:59:59.999999999 sat
please take here detail : https://github.com/jinzhu/now
Comments
Post a Comment