A set of technologies in .NET for building web applications and web services. Miscellaneous topics that do not fit into specific categories.
I see an 8 hour difference with my local time. I expected to see a time same as my local time
@Donald Symmons , it seems the web server time zone is different than as your local time zone, with a difference of 8 hours. DateTime.Now gets the local time where the code runs. An 8 hour difference is expected if, for example, your machine is Pacific Standard Time and the web server time zone UTC.
As suggested, you could store the datetime value in UTC (neither .NET nor SQL Server datetime types are time zone aware) and then convert the time to the time zone of your choosing for display purposes. Similarly, you could use datetimeoffset instead which will include the offset with DatetimeOffset.Now.
It can be a tricky to determine the end client time zone or offset on the server side to display the time in your local time. For that reason, consider formatting the value in client-side javascript from an ISO-8601 datetime format source.