AngularJS date formatting details,

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.