You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on May 15, 2024. It is now read-only.
James Montemagno edited this page Apr 24, 2018
·
4 revisions
Here are frequently asked questions about Preferences:
Is it possible to save DateTime values?
Since each platform does not handle this natively there is no direct API in Preferences to do get and set DateTime. However, you can simply save the Ticks of the DateTime (recommended to use the Universal Time) as a long:
const string MyKey = "dt_key";
public DateTime SavedDateTime
{
get => new DateTime(Preferences.Get(MyKey, DateTime.UtcNow.Ticks, DateTimeKind.Utc));
set => Preferences.Set(MyKey, value.ToUniversalTime().Ticks);
}