How to get specific time of tomorrow's date in datetimeoffset in c#?

I want a DateTimeOffset value for tomorrow's date, 7 AM , Central Standard Time.

My current code is:

var tomorrow = DateTime.Now.AddDays(1);

var tomorrowDate = new DateTime(tomorrow.Year, tomorrow.Month, tomorrow.Day, 07, 00, 00, DateTimeKind.Local);

DateTimeOffset datetimeOffsetInCentralTimeZone = new DateTimeOffset(tomorrowDate, TimeZoneInfo.FindSystemTimeZoneById("Central Standard Time").GetUtcOffset(tomorrowDate));

return datetimeOffsetInCentralTimeZone;

Is this correct? Is there an easier way to get the datetimeoffset value?



Comments

Popular posts from this blog

Spring Elasticsearch Operations

Object oriented programming concepts (OOPs)

Network Error and Timeout on Authorize.net JS