Saturday, July 2, 2011

Localization of Dates in C#

To store current date as UTC in sql server, sql GETUTCDATE() function can be used( in your storedproc).
Note that GETUTCDATE() returns the current datetime in UTC.
In your codebehind you can use the C# ToLocalTime function method to restore a local date and time value that was converted to UTC
DateTime date1 = new DateTime(2011, 4, 13, 2, 30, 0, DateTimeKind.Local);
DateTime utcDate1 = date1.ToUniversalTime();
DateTime date2 = utcDate1.ToLocalTime();

No comments:

Post a Comment

Your project is not referencing the "MonoAndroid,Version=v8.1" framework. Add a reference to "MonoAndroid,Version=v8.1" in the "frameworks" section of your project.json, and then re-run NuGet restore.

I had  the same problem. Reason: file obj/project.assets.json target "MonoAndroid,Version=v7.1" when my project target androi...