I have written a golang program to generate the start date and end date of the month for different locations
if month != "" && year != "" {
var monthInt, _ = strconv.Atoi(month)
var yearInt, _ = strconv.Atoi(year)
timeZone, err := time.LoadLocation("America/Pheonix")
if err != nil {
fmt.Println(err)// nil
}
// currentLocation := time.Now().Location(timeZone) // when I use this it will works
// both are of same type
fmt.Println(reflect.TypeOf(timeZone))
fmt.Println(reflect.TypeOf(time.UTC))
firstOfMonth := time.Date(yearInt, time.Month(monthInt), 1, 0, 0, 0, 0, timeZone)
onlyStartDate := strings.Split(firstOfMonth.Format("2006-01-02 00:00:00 -0000"), " ")
lastOfMonth := firstOfMonth.AddDate(0, 1, -1).Format("2006-01-02 00:00:00 -0000")
onlyLastDate := strings.Split(lastOfMonth, " ")
merchantDb.GetProvidersOfTheMonth(onlyStartDate[0], onlyLastDate[0])
}
But when I run this code it will give me the error of the:-
time: missing Location in call to Date
Why this error is generating and how I will solve this error?
Please any suggestions!