Is it possible in google app engine (go) to format a date using the users local web browser timezone?

huangapple go评论101阅读模式
英文:

Is it possible in google app engine (go) to format a date using the users local web browser timezone?

问题

在Google App Engine(Go语言)中,是否可以使用用户本地的Web浏览器时区来格式化日期?

最终用户应该能够选择/调整他们的时区,但目前使用用户计算机的时区应该就足够了。

英文:

Is it possible in google app engine (go) to format a date using the users local web browser timezone?

Ultimately users should be able to pick/adjust their timezone, but for now the users computer timezone should be sufficient.

答案1

得分: 4

你需要将这些信息通过HTTP请求发送,并确保它是appengine识别的时区之一,然后使用time包进行格式化。

你可以在这里阅读更多关于这个问题的内容:

http://www.goinggo.net/2013/08/using-time-timezones-and-location-in-go.html

英文:

You would need to send that information along the http request and then make sure is one of appengine's recognized timezones and then format it with the time package

you can read more about the whole thing here:

http://www.goinggo.net/2013/08/using-time-timezones-and-location-in-go.html

答案2

得分: 0

根据您的应用程序,一个AppEngine的HTTP请求头应该包含几个变量,即'X-AppEngine-Country',它是请求来源的国家,使用ISO 3166-1 alpha-2国家代码表示,根据客户端的IP地址确定。

然后,您可以使用这个国家代码(例如AU,GB)来检测发送者的时区,并将UTC时间格式化为本地时间。

对于用户选择的时区,您需要传递相关信息,如您所知。

英文:

Depending on your application, but an appengine http request header should include few variables, namely 'X-AppEngine-Country' which is the country from which the request originated, as an ISO 3166-1 alpha-2 country code, determined from the client's IP address.

You may then able to use this country code (i.e. AU, GB) to detect the sender timezone and format the UTC time to local.

http://golang.org/pkg/time/

For user selected timezone, you would need to pass an information in as you may know.

huangapple
  • 本文由 发表于 2014年7月15日 09:30:31
  • 转载请务必保留本文链接:https://go.coder-hub.com/24748597.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定