-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");
                });
3
  • Have you tried the data filter? Commented Nov 27, 2017 at 5: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 Commented Nov 27, 2017 at 5:34
  • Possible duplicate of converting date format in angularjs controller Commented Nov 27, 2017 at 6:25

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.