I have an Windows Console application in C# which need to compare current time with two times stored in DB. Date and Time converted to UTC before inserting into DB. Now, I need to fetch those values and compare only time part with local time. Let say my dates are as follows:
DateTime dt1 = new DateTime(2013, 08, 29, 00, 00, 00)
DateTime dt2 = new DateTime(2013, 08, 29, 23, 59, 59)
as I'm converting these two dates to UTC and storing in DB, my DB values look like '28/08/2013 18:30:00' and '29/08/2013 18:00:00'.
Let say my current local time is '14:00:00' and my condition to check is, my local time should be in between time part of my DB Datetime values. Like
if(DateTime.Now.TimeOfDay >= DBTime1 && DateTime.Now.TimeOfDay <= DBTime2)`
{
//true condition logic
}
If I convert db date time to local and compare, it is working as expected in my local system. My doubt is what if the application is hosted in server in UK and accessing it from India, will time comparison work as expected? Do we need to consider any other things like DST (Day Saving Time) or TimeZone while converting to local time?