How to get the mobile current date time with the 12/24 format .Date and time e.g. April 17, 2020 - 1:15 PM. The date and the time should conform to the preferences the user has set on the device.
how we do it in Xamarin forms.If i write the below in android then how to call in Xamarin forms.
If mobile set to 24 hours then it should display Any one can help me with this.
This is the android snippet Xamarin Forms how can I do it that if I write the below snippet in android then how can I call this in Xamarin forms?
var date = DateTime.Now.ToLocalTime();
var is24hour = Android.Text.Format.DateFormat.Is24HourFormat(this);
var format = is24hour ? "dd/MM/yyyy HH:mm" : "dd/MM/yyyy hh:mm tt";
var dtString = date.ToString(format);
This is how it look like shows in 24 hours format Device setting in 24 hours format Code screen shot