JavaScript Momentjs : How to prevent “Invalid date”?

I have the following code :

var fomattedDate = moment(myDate).format("L");

Sometimes moment(myDate).format("L") returns "Invalid date", I want to know if there is a way to prevent that and return an empty string instead.

Answer:1

I'm using a simple custom directive for a modified input field which occurs throughout my application: app.directive('editor', function() { return { restrict: 'E', templateUrl: '...

I'm using a simple custom directive for a modified input field which occurs throughout my application: app.directive('editor', function() { return { restrict: 'E', templateUrl: '...

  1. angularjs custom directive input validation
  2. angularjs custom directive input
  3. angularjs directive input validation

I want to know if its possible to have tooltip on a collapse anchor tag. The code which is use for collapse is: <a data-toggle="collapse" data-parent="#accordion" href="#collapseOne">Data</...

I want to know if its possible to have tooltip on a collapse anchor tag. The code which is use for collapse is: <a data-toggle="collapse" data-parent="#accordion" href="#collapseOne">Data</...

Background: I am compiling 2 dependent TypeScript files to js, which produces also source maps (one source map per file) using tsc 1.0 I'm using -m commonjs and then use browserify to generate a ...

Background: I am compiling 2 dependent TypeScript files to js, which produces also source maps (one source map per file) using tsc 1.0 I'm using -m commonjs and then use browserify to generate a ...

So, What I'm trying to do is fairly simple with vanilla JS, but I'm using AngularJS and I would like to know how to do it the best way within the framework. I want to update the selected options in a ...

So, What I'm trying to do is fairly simple with vanilla JS, but I'm using AngularJS and I would like to know how to do it the best way within the framework. I want to update the selected options in a ...

  1. angularjs select multiple options
  2. angularjs select multiple ng-options