I've got some code similar to:
[HttpGet("SearchStuff")]
public IActionResult SearchStuff([FromQuery]DateTime from, [FromQuery]DateTime to)
I want to make sure I receive in UTC as follows: If a timezone is specified then convert to UTC If no timezone is specified then assume UTC and specify as UTC
I tried sending as utc from the client like this (Client works in local time), and it formats as I would expect but unfortunately serverside the datetime was converted to local time of the server. If I use ToString("s") the server receives the correct datetime value but unfortunately with DatetimeKind.Unspecified:
protected string Format(DateTime t)
{
return t.ToUniversalTime().ToString("o");
}