I ma using code like
$filter('date')(new Date(), $scope.format);
$scope.format = 'dd-MMM-yyyy';
It works properly in all browsers except firefox. Firefox show value as NaN. How do I fix this issue?
I ma using code like
$filter('date')(new Date(), $scope.format);
$scope.format = 'dd-MMM-yyyy';
It works properly in all browsers except firefox. Firefox show value as NaN. How do I fix this issue?
if your code involves new Date('<dd-MMM-yyyy>')
at some point,
I would like to point it out that Firefox doesn't take that format!
new Date('<dd/MMM/yyyy>')
would be fine.
This may happen due differing implementations in browsers when parsing date strings. The browser will use the locale to parse the date string, and as locals are subject to change, the returning string may not match the parsing method.
You can avoid it by returning the date's time in milliseconds instead of the date's string (which happens when calling the date's empty constructor).
Replace new Date()
with (new Date()).getTime()
, and you should be fine.