AngularJS supports date formatting in two forms: HTML pages and JS Code, angularJS filters $ filter AngularJS are designed to overcome the shortcomings of HTML in application construction. HTML is a well-designed declarative language for static text display, but it seems weak to build WEB applications. So I did some work (you can also think it is a little trick) to let the browser do what I want.
AngularJS supports date formatting in two forms: HTML pages and AngularJS code filters $ filter.
HTML: date_expression is the date type variable you set in $ scope (note that the date object must be correct). It is also the date to be displayed. | it is a delimiter, the first parameter date after the separator indicates that the filter type is to filter the date, and the second parameter format indicates what your date will look like, such as yyyy-MM-dd, the last timezone is the time zone (optional parameter), which is applicable to international websites.
{Date_expression | date: format: timezone }}
You can use the {} expression or ng-bind or ng-model.
{MyDate | date: 'medium '}}
In Javascript code, it is written as follows:
Var myJsDate = $ filter ('date') ($ scope. myDate, 'yyyy-MM-dd ');
In this way, the variable myJsDate you declare will be able to get the value after myDate formatting in $ scope.
The above is a detailed explanation of AngularJS date formatting provided by the editor. I hope you will like it.
For more details about AngularJS date formatting, refer to the PHP Chinese website!