1

i want to show only date value in the web page. im getting value like this

2019-05-24T10:42:42.6899084

javascript code

 $scope.date = $scope.myWelcome.updatedDate;

sample data in sql server

    UpdatedDate
    2019-05-24 10:27:01.6972592

Json Response

{"id":8,"updatedDate":"2019-05-24T12:48:25.3853657"}

Exp OP -

24-05-2019

HTML

<h3>{{ date.date |  date:'dd/MM/yyyy'}}</h3>

2 Answers 2

2

you can use slice(0, 10)

$scope.date = $scope.myWelcome.updatedDate.slice(0, 10);

//output

2019-05-24

var d = {"id":8,"updatedDate":"2019-05-24T12:48:25.3853657"}

var a = d.updatedDate.slice(0, 10);

console.log(a);

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

Comments

1

You can use date filter of angularjs.

{{ data.updatedDate |  date:'dd/MM/yyyy'}}

Demo

8 Comments

@krishnamohan it is working, you should see 24/05/2019 below hello world text.
@krishnamohan for me i can able see 24/05/2019 under hello world text
@krishnamohan You do not need the demo anyway, just use the code above.
<h3>{{ data.updatedDate | date:'dd/MM/yyyy'}}</h3> not working, getting error
@krishnamohan can you also write details of the error that you are getting please.
|

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.