Search code examples
c#htmlangulartwitter-bootstrap

Timepicker is adding the time zone to the input date


The bootstrap timepicker is passing data that looks like this:

"Mon Jan 01 0001 17:00:02 GMT-0456 (Eastern Standard Time)"

When passed to the api, the string is cast to the C# datetime type except that the time is changed from 5pm to another time due to the GMT-0456 time zone data in the string. Here is after saving to the database: "0001-01-03 09:56:10.0000000" How can I ensure that the time remains the same as the user inputs in the UI (5PM)?

https://angular-ui.github.io/bootstrap/#!#%2Ftimepicker


Solution

  • The solution was to take given datetime, convert it to a string, parse out the time from that string, create a new date using the hours and minutes retrieved from prior, and then format that newly created date into ISO 8601 format. Then pass this new date into the api instead of the one that is created by the timepicker.