Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to format the date using local culture using the blazor <InputDate /> tag

I am using the tag in my Blazor app. But how can i format the date using my own culture ?

            <InputDate class="form-control" @bind-Value="@ValidDate" @bind-Value:culture="nl-BE" @bind-Value:format="dd/MM/yyyy" />  

enter image description here

regards Dieter

like image 474
Dieter Avatar asked Aug 15 '19 11:08

Dieter


1 Answers

The answer is @bind-Value:format, like so

@page "/"

<EditForm Model="@CurrentPerson">
    <InputDate @bind-Value="@CurrentPerson.DateOfBirth" @bind-Value:format="dd/MM/yyyy"/>
</EditForm>

@code
{
    Person CurrentPerson = new Person();
    public class Person
    {
        public DateTime DateOfBirth { get; set; } = DateTime.Now;
    }
}

There is also the option of using bind-Value:culture.

like image 119
Peter Morris Avatar answered Nov 15 '22 11:11

Peter Morris