I have this code :
var dt = moment(cdt).format("L");
At some dates moment(cdt).format("L")
returns Invalid date
, So how can I return an empty string instead invalid date
.
I have this code :
var dt = moment(cdt).format("L");
At some dates moment(cdt).format("L")
returns Invalid date
, So how can I return an empty string instead invalid date
.
With moment.js you can check if a date is valid with the method .isValid()
, for instance:
moment(cdt, 'L', true).isValid()
moment("12/13/2020", "DD/MM/YYYY", true).isValid()
should return False
.