简体   繁体   中英

DateTime selector format in ASP.NET

I want to change ASP.NET datetime from US to GB format.

I have an HTML page with:

<input asp-for="BirthDay" />

and its corresponding PageModel with:

public DateTime BirthDay { get; set; }

I get a date selector with the US date format:

Month/Day/Year

Instead I want to use the UK date format:

Day/Month/Year

I tried playing around with CultureInfo and some attributes to no avail. Any ideas?

Here is a screenshot showing the problem:

想从 US 格式更改为 GB 格式

Have you tried with asp-format ? For example something like that:

<input asp-for="BirthDay" asp-format="{0:dd/MM/yyyy HH:mm}" />

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM