Skip to Content
Flask Framework Cookbook - Second Edition
book

Flask Framework Cookbook - Second Edition

by Shalabh Aggarwal
July 2019
Beginner to intermediate
302 pages
9h 38m
English
Packt Publishing
Content preview from Flask Framework Cookbook - Second Edition

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" 
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Writing a Web Application with Flask

Writing a Web Application with Flask

Doug Farrell
Mastering Flask

Mastering Flask

Jack Stouffer

Publisher Resources

ISBN: 9781789951295Supplemental Content