A function in my web application makes a call to custom API (written in C#) that stores, among many things, current date & time to the database and in the API, a value is assigned simply using the DateTime.Now
method.
And the above mentioned date & time value is retrieved in the following fashion:
DateTime? dt = !string.IsNullOrEmpty((dr["RecordDate"]).ToString()) ?
Convert.ToDateTime(dr["RecordDate"].ToString()) : (DateTime?) null;
When I assign the value in dt
from above code to a JavaScript variable, I end up with a value /Date(1415049596057)/
. I've seen date & time values being formatted in different ways before but I don't think I've seen anything quite like this. I suppose I'm not handling the conversion process correctly but I'm really puzzled by this.
UPDATE:
Value assignment to the DateTime variable is done as follows:
using (var con = new SqlConnection(Service.GetSiteSetting(_httpContextAccessor.Current(), customdb))
{
con.Open();
var cm = new SqlCommand { CommandType = CommandType.StoredProcedure, CommandText = "SaveRecord", Connection = con };
... // not showing other parameters
cm.Parameter.Add(new SqlParameter("@RecordDate", SqlDbType.DateTime) { Value = DateTime.Now });
...
cm.ExecuteNonQuery();
}