go - Get given timezone timestamp -


i playing around timezone , noticed wierd.

i in bst timezone hour ahead of gmt.

        := time.now()         location, _ := time.loadlocation("atlantic/cape_verde")         timeatzone := now.in(location)         fmt.println(timeatzone)         timestamp = timeatzone.unix()         fmt.println(timestamp)         fmt.println(now.add(-time.hour).utc().unix())         fmt.println(now.utc().unix()) 

you notice timestamp of bst current timezone.

how timestamp of gmt???

http://play.golang.org/p/oq0irya0h7

unix time absolute. there no "bst unix time." there no "atlantic/cape_verde" unix time." there unix time. number of seconds since specific moment (00:00:00 coordinated universal time (utc), thursday, 1 january 1970, not counting leap seconds).

time zones related representation of time, not time itself. same moment me, wherever in world (leaving einstein aside moment). happen call moment different things. setting location on *time indicates how display time. if "timestamp" mean "string representing time," can utc timestamp time.now().utc().string().


Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -