I want to format the date like that: yy-MM-dd
I trying to format the date like that:
<Label Grid.Row="0" Grid.Column="0" Text="{Binding Dat, StringFormat='{0:dd.MM}'}" XAlign="Start" YAlign="Center" TextColor="White" FontAttributes="Bold" FontSize="13"/>
but I receive full year - yyyy
CodePudding user response:
You can achieve "yy-MM-dd" format by using ToString("yy-MM-dd") method in the code behind.Below is the code snippets for your reference:
<Label Text="{Binding Dat}"></Label>
in page.cs:
public string Dat { get; set; }
public MainPage()
{
InitializeComponent();
Dat = DateTime.Now.ToString("yy-MM-dd");
BindingContext = this;
}