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

Popular posts from this blog

javascript - How to get current YouTube IDs via iMacros? -

c# - Maintaining a program folder in program files out of date? -

emulation - Android map show my location didn't work -