parsing - How to parse Date in IST format in Golang? -


time.date(t.year(), t.month(), time.now().day(), 10, 0, 0, 0, time.utc) 

i want set datetime of 10:00:00 in ist format in golang.

it depends on format of time have @ hand. go has standard time formats ready consts in time package, can specify own standard if it's custom. regarding time zone, can parse or output time in specific time zone. here example of parsing time string in ist, , outputting utc. it's not clear question precise problem hope helps:

// first, create instance of timezone location object loc, _ := time.loadlocation("asia/kolkata")  // our custom format. note format must point exact time format := "jan _2 2006 3:04:05 pm"  // timestamp timestamp := "jun 25 2015 10:00:00 am"  // parse it, considering it's in ist t, err := time.parseinlocation(format, timestamp,  loc)  // printing prints in ist, can set timezone utc if want fmt.println(t, err)  // example - getting utc timestamp fmt.println(t.utc()) 

Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -