Can someone give me the easiest way to create a ZonedDateTime, given "4:30 pm" and "America / Chicago".
I want this object to represent this time for the current date in this time zone.
Thanks!
I tried this ... but it seems to actually give me an instant in the local time zone, which gets the offset when creating the zonedDateTime.
string time = "4:30pm";
string timezone = "America/Chicago";
DateTime dateTime;
if (DateTime.TryParse(time, out dateTime))
{
var instant = new Instant(dateTime.Ticks);
DateTimeZone tz = DateTimeZoneProviders.Tzdb[timezone];
var zonedDateTime = instant.InZone(tz);
source
share