- Flask Framework Cookbook(Second Edition)
- Shalabh Aggarwal
- 102字
- 2021-06-24 13:58:03
Getting ready
Just like any JS library, Moment.js can be included in our app in the following manner. We will just have to download and place the JS file, moment.min.js, in the static/js folder. The Moment.js file can be downloaded from http://momentjs.com/. This file can then be used in an HTML file by adding the following statement along with other JavaScript libraries:
<script src="{{ url_for('static', filename='js/moment.min.js') }}"></script>
The basic usage of Moment.js is shown in the following code. This can be done in the browser console for JavaScript:
>>> moment().calendar(); "Today at 1:35 P" >>> moment().endOf('day').fromNow(); "in 10 hours" >>> moment().format('LLLL'); "Monday, December 17, 2018 1:35 PM"