I have a DateTime in c # code that I'm trying to convert it in a string before sending it to the front end.
For example, I have this C#:
DateTime utcN = DateTime.UtcNow;
string utcNow = utcN.ToString(); //an example "12/31/2099 12:00:00 AM"
And in the front end javascript I convert this to date as:
var date = new Date(Date.parse(utcNow));
Some users are complaining about NaN values, but since I can't debug it is difficult to understand why this is happening!
ToString()produce? Are your users in different Cultures than the server? Can you give us a minimal reproducible example?new Date(Date.parse(utcNow))will produce exactly the same result asnew Date(utcNow).