请允许我说,现在,我的系统时区是+5GMT。
右上机01/14/2012 05:52PM/code> 我想把它变成像PST时代一样的平时区。
1/14/12 4:52:50 AM PST
反之,PST改为GMT
请允许我说,现在,我的系统时区是+5GMT。
右上机01/14/2012 05:52PM/code> 我想把它变成像PST时代一样的平时区。
1/14/12 4:52:50 AM PST
反之,PST改为GMT
TimeZoneInfo timeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById("Pacific SA Standard Time");
DateTime newDateTime = TimeZoneInfo.ConvertTime(existingDateTime, timeZoneInfo);
http://www.xiirus.net/articles/article-_net-convert-datetime- from-one-timezone-to-another-7e44y.aspx>here
Also take a look at Converting Between Any Two Time Zones
在上述“HarisHasan”答复的启发下,以下方法将产生《标准指示》,不管贵国的法规如何运作:
public static DateTime GetPacificStandardTime()
{
var utc = DateTime.UtcNow;
TimeZoneInfo pacificZone = TimeZoneInfo.FindSystemTimeZoneById("Pacific Standard Time");
var pacificTime = TimeZoneInfo.ConvertTimeFromUtc(utc, pacificZone);
return pacificTime;
}
TimeZoneInfo.FindSystemTimeZoneById("Pacific SA Standard Time");
Will fail if we deploy the application in Linux (In case of .NET Core), found this nice library which will give correct TimeZoneInfo in windows and Linux "TimeZoneConverter", using this we can convert like
using TimeZoneConverter;
TimeZoneInfo pst =TZConvert.GetTimeZoneInfo("Pacific Standard Time");
DateTime newDateTime = TimeZoneInfo.ConvertTime(existingDateTime, pst);
What is the use of default keyword in C#? Is it introduced in C# 3.0 ?
I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...
I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...
I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...
I have two EF entities. One has a property called HouseNumber. The other has two properties, one called StartHouseNumber and one called EndHouseNumber. I want to create a many to many association ...
How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...
Since I cannot order my dictionary, what is the best way of going about taking key value pairs and also maintaing an index?
Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...