0

I copied an example from canvasJS to my ASP.NET MVC project.

It works, but in the example it's passing a date to the view as double:

List<DataPoint> dataPoints = new List<DataPoint>();
 
dataPoints.Add(new DataPoint(1496255400000, 2500));
dataPoints.Add(new DataPoint(1496341800000, 2790));
dataPoints.Add(new DataPoint(1496428200000, 3380));
ViewBag.DataPoints = JsonConvert.SerializeObject(dataPoints);           
 
return View();

According to the example, these dates are June 1st - June 3rd (not sure what year). Now that I want to use my own data.

How do I convert my DateTime into this double date format?

Thanks

Shoejep
  • 4,414
  • 4
  • 22
  • 26
Kobi
  • 117
  • 2
  • 12
  • Does this answer your question? [How do I get epoch time in C#?](https://stackoverflow.com/questions/9453101/how-do-i-get-epoch-time-in-c) – Shoejep Nov 07 '20 at 08:32
  • No,this generate 10 digits, it looks like something else, can't understand what is this 13 digits double format (1496255400000) – Kobi Nov 07 '20 at 08:40
  • It means they've included the milliseconds as well, i.e. `Console.WriteLine((DateTime.Now - new DateTime(1970, 1, 1)).TotalMilliseconds.ToString("0"));` – Shoejep Nov 07 '20 at 08:54

0 Answers0