【发布时间】:2017-06-26 16:26:36
【问题描述】:
我在 MAC 操作系统中创建货件时遇到问题。在 Windows 操作系统中,该网站运行良好。任何帮助将不胜感激
谢谢。
代码:
createOrUpdateShipment: function (shipmentHeader) {
----------
var tzm= (/\((.*)\)/.exec(new Date().toString())[1]);
return $http.post('/shipment/CreateOrUpdateShipment?tzm='+tzm, shipmentHeader)
},
在控制器中
public ActionResult CreateOrUpdateShipment(ShipmentInfo shipmentInfo, string tzm)
TimeZoneInfo tzi = TimeZoneInfo.FindSystemTimeZoneById(tzm);
shipmentInfo.ServiceInfo.READYDATETYPE = TimeZoneInfo.ConvertTime(shipmentInfo.ServiceInfo.READYDATETYPE,tzi);
当我尝试使用 MAC 操作系统创建货件时出现以下错误
获取错误时区未找到异常。未找到时区 ID“CST”
【问题讨论】:
-
与其依赖可能因语言和平台而异的命名时区,我强烈建议在 .NET 中使用
DateTimeOffset或像 NodaTime 这样的包来处理本地化的日期和时间。 -
这个问题已经回答了吗?