Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Monday, February 13, 2017 3:13 PM
How to convert this date to datetime '2/13/2017 12:00:00 AM -05:00'
tried this DateTimeOffset myDTO = DateTimeOffset.ParseExact(dateoffset, "MM/dd/yyy h:mm:ss tt zzz", CultureInfo.InvariantCulture); still gives me mismatch error
Thank you
All replies (1)
Monday, February 13, 2017 4:13 PM âś…Answered
A DateTimeOffSet object actually has a DateTime property that you can use :
var date = YourDateTimeOffset.DateTime;
However, it looks like you want to actually parse a string value and convert it to a DateTime, which you could do as follows :
var now = "2/13/2017 12:00:00 AM -05:00";
var offset = DateTimeOffset.Parse(now);
var date = offset.DateTime;