golang 获取当前日期,月份第一天和最后一天

为什么80%的码农都做不了架构师?>>>   hot3.png

    now := time.Now()
    currentYear, currentMonth, _ := now.Date()
    currentLocation := now.Location()

    firstOfMonth := time.Date(currentYear, currentMonth, 1, 0, 0, 0, 0, currentLocation)
    lastOfMonth := firstOfMonth.AddDate(0, 1, -1)

    fmt.Println(firstOfMonth.Unix())
    fmt.Println(lastOfMonth.Unix())
    
    layout := "2006-01-02 15:04:05"
    loc, _:= time.LoadLocation("Asia/Chongqing")
    zero_day, _ := time.ParseInLocation(layout, "1949-10-01 00:00:00", loc)

转载于:https://my.oschina.net/zdglf/blog/836062

你可能感兴趣的:(golang 获取当前日期,月份第一天和最后一天)