简体   繁体   English

如何从 DateTime.Now 获取时区名称

[英]How to get Time zone name from DateTime.Now

How to get time zone name(eg: Europe/London, Asia/Kolkata, etc.) from DateTime.Now() in c#如何从 c# 中的DateTime.Now()获取时区名称(例如:欧洲/伦敦、亚洲/加尔各答等)

Please help me请帮我

Thanks, King谢谢大王

DateTime.Now() returns current computer localtime. DateTime.Now() 返回当前计算机本地时间。

If you want get current computer timezone, read this:如果您想获取当前计算机时区,请阅读以下内容:
https://docs.microsoft.com/en-us/dotnet/api/system.timezone.currenttimezone?view=net-5.0 https://docs.microsoft.com/en-us/dotnet/api/system.timezone.currenttimezone?view=net-5.0

You can't get zone using DateTime.Now()您无法使用 DateTime.Now() 获取区域

The below piece of code gives you the daylight time and standard time.下面的代码为您提供了白天时间和标准时间。

TimeZone localZone = TimeZone.CurrentTimeZone;

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

相关问题 将DateTime.Now转换为其他时区 - Converting DateTime.Now To A Different Time Zone NSubstitute DateTime.Now() 如何让 DateTime.Now() 返回不断增加的日期和时间? - NSubstitute DateTime.Now() How can I get the DateTime.Now() to return an ever increasing date and time? Ajust DateTime.Now用于另一个时区的服务器 - Ajust DateTime.Now for a server in another time zone DateTime.now不响应时区更改 - DateTime.now doesnt respont to time zone changes 如何找到从数组到DateTime.Now的最接近的较大时间 - How to find closest bigger time from an array to DateTime.Now DateTime.Now作为文件名 - DateTime.Now as file name 您如何获得从上一个星期二(或任何日期名称)到 DateTime.Now 或今天的日期过去了多少天? - How do you get how many days passed from the previous Tuesday (or any day name) until DateTime.Now or todays date? 如何为datetime添加更多时间。现在解析它然后重置回原来的datetime.now? - How do i add more time to the datetime.now parse it then reset back to the original datetime.now? 如何将datetime.now格式转换为此datetime格式? C# - How to get datetime.now format into this datetime fomat? C# 如何使用 Linq c# 从 SQL Server 数据库中获取短日期时间并与 DateTime.Now 进行比较 - How to get a short DateTime from SQL Server database and compare with DateTime.Now using Linq c#
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM