-2

i got the error like this ..

enter image description here

help how to fix this error

Sridhar kumar
  • 17
  • 1
  • 1
  • 10
  • 2
    Please refer below. https://stackoverflow.com/questions/23593052/format-javascript-date-to-yyyy-mm-dd – Dumi Oct 30 '18 at 10:44
  • 3
    Possible duplicate of [ASP.NET MVC JsonResult Date Format](https://stackoverflow.com/questions/726334/asp-net-mvc-jsonresult-date-format) – marsze Oct 30 '18 at 10:45
  • 1
    Exactly what you wnating..https://stackoverflow.com/questions/42070895/converting-json-date-using-javascript – TanvirArjel Oct 30 '18 at 10:51

2 Answers2

1

You can make that using available date methods like this:

var d = new Date(1540995900000);
var date_string = d.getUTCFullYear() + '-' + (d.getUTCMonth() + 1) + '-' + d.getUTCDate();
r00t
  • 468
  • 3
  • 10
-1

Create a JavaScript function as following an just pass the date.

function formatDate(date) {
    var d = new Date(date),
        month = '' + (d.getMonth() + 1),
        day = '' + d.getDate(),
        year = d.getFullYear();

    if (month.length < 2) month = '0' + month;
    if (day.length < 2) day = '0' + day;

    return [year, month, day].join('-');
}