Reputation: 91
I am using datepicker in xamarin forms but it shows date format by defualt "MM/dd/yyyy" and i have changed it to "dd/MM/yyyy" but when i bind the datepicker with viewmodel on save command then it changed to "MM/dd/yyyy" on my model and my model date property is in string type. also when i pass any string date from database to datepicker it does not change the date in this i have to convert date to again "MM/dd/yyyy", I want to ask is their any solution to format datepicker to parmanent to "dd/MM/yyyy" because i want to save and show date in "dd/MM/yyyy" format. Thanks u in advance.
Upvotes: 1
Views: 1054
Reputation: 78
Try to use this method. Date format displaying depends on the current culture in your app. Set current culture globally by using this method inside App.xaml.cs.
Also take a look at DateTimeFormatInfo
property in your cultureInfo object
using System.Globalization;
using System.Threading;
private void SetCultureToUSEnglish()
{
CultureInfo englishUSCulture = new CultureInfo("en-US");
CultureInfo.DefaultThreadCurrentCulture = englishUSCulture;
}
Upvotes: 1