Programming Journal C#, Java, SQL and to a lesser extent HTML, CSS, XML, and regex. I made this so other programmers could benefit from my experience.

Tuesday, December 23, 2008

Get the Current Time for Database Storage

To get the current datetime in UTC format in .net use following:

DateTime dateUTC = DateTime.Now.ToUniversalTime();
You can then store this date in your database.
If you want to display it back to local time use:


DateTime dateLocal = dateUTC.ToLocalTime();


Reference: http://forums.asp.net/t/1217716.aspx

No comments: