AngularJS date formatting details,
AngularJS is designed to overcome the shortcomings of HTML in building applications. 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.
Copy codeThe Code is as follows:
{Date_expression | date: format: timezone }}
You can use the {} expression or ng-bind or ng-model.
Copy codeThe Code is as follows:
{MyDate | date: 'medium '}}
<H1 ng-bind = "myDate | date: 'yyyy-MM-dd'">
In Javascript code, it is written as follows:
Copy codeThe Code is 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.
Articles you may be interested in:
- Multiple methods for formatting js timestamps into date formats
- Php formatted Date and Time Format example sharing
- C # summary of the DateTime date format display method
- In PowerShell, Get-Date is used to Get the Date and time and format the output.
- Js time and date formatting and encapsulation Functions
- $ Apply () method in angularJS
- AngularJS router User Guide
- Use AJAX in AngularJS
- Angularjs client compresses image files and uploads instances