I have the following code that take in input scheduleConfiguration.Time
in the UTC and return ticks
in local time.
scheduleConfiguration.Time equal {9/13/2015 10:00:00 AM} in UTC
var localTime = scheduleConfiguration.Time.ToLocalTime(); {9/13/2015 1:00:00 PM} in Local
var executionTime = new TimeSpan(localTime.TimeOfDay.Ticks);
I changed my data contract scheduleConfiguration.Time
, so I need to use TimeSpan TimeOfDay
instead of DateTime Time
, but I need to have the same executionTime
. So I do next
var local time = DateTime.Now.Date.Add(scheduleConfiguration.TimeOfDay);//{9/13/2015 10:00:00 AM} in Local
var executionTime = new TimeSpan(localTime.Ticks);
So I have the difference in 3 hours (and I have UTC +3 time zone)
How to get the same result as for DateTime in the first situation?