sooon
sooon

Reputation: 4888

Angularjs - javascript date format issue

I tried to format my date:

var startdate = new Date(someDate).toLocaleDateString('en-GB', {  
                    year: 'numeric',
                    month: 'short',
                    day: 'numeric'
                }).split(' ').join('-');

and I console.log it appear:

3-Mar-2016

which is exactly what I want. But what appear in html when I {{someDate}} or {{someDate.toString()}} it become:

Thu Mar 03 2016 00:00:00 GMT+0800 (MYT)

How to resolve this?

Upvotes: 0

Views: 29

Answers (1)

Manish Kumar
Manish Kumar

Reputation: 595

refer to this link AngularJs:API:date you can format it like this

{{someDate| date:'dd-MM-yyyy'}}

Upvotes: 2

Related Questions