I have an issue with time saved in the database. It does not give accurate time with my local time. If I insert data into the table with DateTime.Now, I thought it should get the time automatically in the local time and insert, so that when it displays, it will show exactly the time an event occurred.
Here is how I inserted the date and time with DataType: datetime
objCMD.Parameters.Add("@LastLogin", SqlDbType.DateTime, 100).Value = DateTime.Now;
OR
cmd.Parameters.AddWithValue("@CreatedDate", DateTime.Now);
The displaying the date and time I use
timelbl.Text = Convert.ToDateTime(Session["LastLogin"]).ToString();
or when displaying in the Gridview I use
<asp:BoundField DataField="LastLogin" HeaderText="Date and Time" HeaderStyle-Font-Bold="false" />
Please what can I do to make the date and time work according to the real time local time and according to the machine time?