Formatting date shown in input text
spac3cas3 opened this issue · 1 comments
spac3cas3 commented
I have the following code in my application, where I have configured the calendar for Norwgian culture:
<input type="text" onfocus=@focussed value=@selectedDate class="form-control blzinput form-control-sm m-3" placeholder="Velg dato" />
<DatePicker FormatProvider="@(new System.Globalization.CultureInfo("nb-NO"))" Visible=@visible Selected=@HentBaner />
The text shown in text input after the calendar closes is still in english though. Is it possible to change this also to Norwegian. Or maybe configure so it displays a numerical date instead of eg "Monday, 11 March 2019"
nheath99 commented
The DatePicker simply returns a nullable LocalDate object, this can be displayed in whatever format you wish. I would suggest doing something like this:
@{
var cultureInfo = new System.Globalization.CultureInfo("nb-NO");
}
<input type="text" onfocus=@focussed value=@selectedDate?.ToString("D", cultureInfo) class="form-control blzinput form-control-sm m-3" placeholder="Velg dato" />
<DatePicker FormatProvider="cultureInfo" Visible=@visible Selected=@HentBaner />
Replace the "D" with whatever format you want to display. "D" is the default for LocalDate.ToString