golang 获取当月最后一天日期

    now := time.Now()
    year, month, day := now.Date()

    //fmt.Println(year, month, day)       //2021 September 1
    fmt.Println(year, uint(month), day) //2021 9 1

    //获取月份最后一天
    lastTime := now.AddDate(0, 1, -1)
    lastYear, lastMonth, lastDay := lastTime.Date()
    fmt.Println(lastYear, int(lastMonth), lastDay) //2021 9 30

 

上一篇:如何用20行Python代码打造一个微信群聊助手?


下一篇:relay.build调用关系