简体   繁体   English

Web服务中时区的格式,将被许多不同的平台使用

[英]Format for time zone in web service that will be used by many different platforms

I'm currently working on a web service using .NET that returns information about the users in a system. 我目前正在使用.NET进行Web服务,该服务返回有关系统中用户的信息。 This web service has to be general enough to be used by other systems written in Java, PHP etc. My problem is that it has to return the default time zone and I'm not sure about what format I should use to return the time zone, so that it can be easily used by other systems. 此Web服务必须足够通用才能被其他用Java,PHP等编写的系统使用。我的问题是它必须返回默认时区,并且我不确定应该使用哪种格式返回时区。 ,以便其他系统可以轻松使用它。

What do you recommend? 您有什么推荐的吗?

The most adopted way of describing time zones is the "Olson" zone info database: http://www.iana.org/time-zones . 描述时区的最常用方法是“ Olson”时区信息数据库: http : //www.iana.org/time-zones

Most programming languages and frameworks have libraries to do datetime calculations based on that zoneinfo database. 大多数编程语言和框架都有基于该zoneinfo数据库进行日期时间计算的库。 In some cases it is even built in (PHP that I know of), in Python the default implementaion is called pytz . 在某些情况下,它甚至是内置的(我知道PHP),在Python中,默认实现称为pytz If your are looking for JavaScript implementations there is a time zone detection script here and a datetime calculation script here . 如果您正在寻找JavaScript实现,则这里有一个时区检测脚本这里datetime计算脚本

Only if you are working with very obscure frameworks/languages will you need to implement datetime logic around the zoneinfo database yourself. 仅当您使用非常晦涩的框架/语言时,才需要自己围绕zoneinfo数据库实现日期时间逻辑。

Since you are working with .NET you may find this question helpful: .NET TimeZoneInfo from Olson time zone . 由于您使用的是.NET,因此您可能会发现此问题有所帮助: Olson时区的.NET TimeZoneInfo Consider using a library like noda-time which foregoes .NET's TimeZoneInfo in favour of Olson timezones. 考虑使用像noda-time这样的库,该库放弃了.NET的TimeZoneInfo而改用Olson时区。

More .NET info her: TimeZoneInfo vs. Olson database .NET的更多信息: TimeZoneInfo与Olson数据库

I would recommend using the UTC time zone for dates/times. 我建议使用UTC时区作为日期/时间。 Most languages/libraries have a method for converting UTC to any time zone desired. 大多数语言/库都有将UTC转换为所需的任何时区的方法。

If you need to represent the actual default time zone for the user then use the offset from UTC (ex: Eastern Time is -5). 如果您需要为用户表示实际的默认时区,请使用UTC的偏移量(例如:东部时间为-5)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 构建供多个平台使用的Web服务-我应使用哪种格式? - Building a web service to be consumed by multiple platforms - what format should i use? 不同平台之间的异步Web服务 - asynchronous web services between different platforms 在不同平台上使用 Web 服务的分布式事务 - Distributed transaction using web services on different platforms WSDL来自与用于生成Web服务的WSDL不同的Web服务 - WSDL got from a web service different from WSDL used to produce the web service Asp Mvc 3-宁静的Web服务,可在多个平台上使用 - Asp Mvc 3 - Restful web service for consuming on multiple platforms 每次使用Jmeter调用时如何将不同的参数传递给Web服务 - How To Pass Different Parameters To web Service Every Time It Is Called With Jmeter 每次我请求时,Web服务都会返回不同的值 - Web service returns different value each time I request Azure ML 时间序列预测 model 的数据输入格式(调用服务)部署为 web 服务(Python) - Data input format (call the service) for Azure ML time series forecast model deployed as a web service (Python) 带有许多请求的.NET Web服务 - .NET web service with many requests Web服务的安全性有很多方法 - security for web service with many methods
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM