I'm trying to format a time.Time
type to a particular time of yesterday (particularly 23:59:59)
I have one function which converts current time to IST
func getTimeInIST() time.Time {
loc, _ := time.LoadLocation("Asia/Kolkata")
now := time.Now().In(loc)
return now
}
another function which converts to the day before
func GetYesterdaysDateFromTime() time.Time{
return getTimeInIST().AddDate(0, 0, -1)
}
I want to format the above to a time stamp of date 2009-06-12 23:59:59
for which I do
yesterday := common.GetYesterdaysDateFromTime()
yesterday.Format("2006-01-02 23:59:59")
but I get this 2019-06-11 118:589:589
what am I doing wrong?