Home  >  Article  >  Backend Development  >  ASP.NET Core returns Json DateTime format

ASP.NET Core returns Json DateTime format

PHP中文网
PHP中文网Original
2017-06-17 16:27:562239browse

When

ASP.NET Core returns Json format, if the returned data contains the DateTime type, how to customize its format? The configuration is as follows:

<code class="sourceCode cs">services.<span class="fu">AddMvc</span>().<span class="fu">AddJsonOptions</span>(opt =>
{
    opt.<span class="fu">SerializerSettings</span>.<span class="fu">DateFormatString</span> = <span class="st">"yyyy-MM-dd HH:mm"</span>;
});</code>

References:

  • Json date being serialized to wrong format

The above is the detailed content of ASP.NET Core returns Json DateTime format. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn