I have a TimeZone received from customer and I use it to set expiration DateTime so that it is UTC equivalent of "End of Month" in customer's time zone.
I tried this:
var current = timezone.ToUniversalTime(DateTime.UtcNow);
But could not manage to work. Can anybody help me with that?
You can try like this:
DateTime utcTime = new DateTime(2016,2,10,10,15,00);
var tz = TimeZoneInfo.FindSystemTimeZoneById("Your Time Zone");
var tzTime = TimeZoneInfo.ConvertTimeFromUtc(utcTime, tz);
//To get time in UTC
var utcTime = TimeZoneInfo.ConvertTimeToUtc(tzTime, tz);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With