The PHP time()
function returns the current time measured in the number of seconds since the Unix Epoch (January 1 1970 00:00:00 GMT).
So to mimic this functionality in C#, try this:
private static double GetUnixEpoch(this DateTime dateTime)
{
var unixTime = dateTime.ToUniversalTime() -
new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
return unixTime.TotalSeconds;
}
Usage:
var unixTime1 = DateTime.Now.GetUnixEpoch();
Note: GetUnixEpoch
returns a double
.
So your code should read like this:
List<double> _data = new List<double>();
foreach (DataRow row in dt.Rows)
{
_data.Add(DateTime.Now.GetUnixEpoch());
_data.Add((double)Convert.ToDouble(row["S11"]));
}
JavaScriptSerializer jss = new JavaScriptSerializer();
chartData = jss.Serialize(_data);
Response.Write(chartData);