-1

I am using angularJs, in this fetching date from the database, in response I get "2017-11-25T18:30:00.000Z" date in this format. "2017-11-25" in the angular controller. I tried different suggestion it didn't work. I only have to change the "jobBatchDate" format in scripting part only.

Can anyone help me out? Thanks :)

$scope.File_Request = function (jobCarrierName,jobFileType,jobBatchDate) {
            // $scope. = [];
            $scope.jobName = jobCarrierName;
            $scope.jobFile = jobFileType;

            $scope.batchDate = jobBatchDate;
                $http({
                method: 'GET',
                url: '../fileReCreate/',
                params: {"carrier": $scope.jobName,"filetype": $scope.jobFile,"batchDate":$scope.batchDate},
                headers: {'Content-Type': 'application/json'}
            })
                .success(function (data, status) {
                    // $scope.scanformdetail = data;
                    alert(data.toString());
                    console.log("File Re-Create Response");
                    // $scope.dispense = true;

                })
                .error(function (data, status) {
                    alert("Error in Re-Creating File");
                });
SGG
  • 135
  • 1
  • 3
  • 15
  • Have you tried the `data filter`? – Ved Nov 27 '17 at 05:25
  • @ved yes I have thought to do it, but I need to covert this in scripting part only before it reach to HTML side – SGG Nov 27 '17 at 05:34
  • Possible duplicate of [converting date format in angularjs controller](https://stackoverflow.com/questions/41826731/converting-date-format-in-angularjs-controller) – Harshal Limaye Nov 27 '17 at 06:25

1 Answers1

0

Use a date filter

jobBatchDate = $filter('date')(jobBatchDate, "yyyy-MM-dd"); 
$scope.batchDate = jobBatchDate;

Here is the official AngularJS Doc for various other date formats https://docs.angularjs.org/api/ng/filter/date

skdonthi
  • 1,308
  • 1
  • 18
  • 31