-1

is there any way to convert formatted date to original date string in angular JS?

Here is the code that I have tried :

$scope.sprintListData.sprintDate.startSprintDate = $filter('date')($scope.sprintListData.sprintDate.startSprintDate, 'dd/MM/yyyy'); 

now i want to convert dd/MM/yyyy to original date string.

i tried new Date($scope.sprintListData.sprintDate.startSprintDate)

Dixit
  • 1,359
  • 3
  • 18
  • 39

3 Answers3

0

Try this

   var startdate=$scope.sprintListData.sprintDate.startSprintDate
   var splitarry=startdate.split("/"); 
   var month="splitarray[1]; 
   var day=splitarray[0]; 
   var year =split(array[1]); 
   var newDateobj=new Date("month+"/"+day+"/"+year); 
    alert(newDateobj+"");
Hassan Tariq
  • 730
  • 7
  • 15
0

You can use moment.js fro date formatting like as-

var date=    moment(new Date($scope.sprintListData.sprintDate.startSprintDate)).format();

I hope this may help you.

0

This should work.

//parse a date in dd/mm/yyyy format
function parseDate(input) {
   var parts = input.split('/');
   return new Date(parts[2], parts[1]-1, parts[0]);
}

alert(parseDate($scope.sprintListData.sprintDate.startSprintDate));

Please refer to this link for more detailed answer: Why does Date.parse give incorrect results?

Community
  • 1
  • 1