I want to make a simple program of golang which only tell me the current month start date and and month's end date. There is also a condition in this is that if the user will entered the month and year then it will give me the start date and end date of that year and month. For this I have tried the below program but it will not giving me the right results:
package main
import (
"fmt"
"time"
)
func main() {
var year int
var month int
year = 2018
month = 1
if year != 0 && month != 0 {
t2 := time.Now().AddDate(year, month, 0)
fmt.Println(t2)
} else {
t2 := time.Now().AddDate(0, 0, 0)
fmt.Println(t2)
}
}
Can any body tell me how I will correct the program.
Thanks in advance.