Documents

Title
Moment.js
Description
Moment.js is a javascript that processes and displays date and time.
Category
Date
Library
Moment.js
Include Files
<!-- Add Moment.js, If change language, add language file » https://cdnjs.com/libraries/moment.js -->
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.20.1/moment.min.js"></script>
Basic markup

        <script>
            window.addEventListener('load', function () {
                moment().format();
            })
        </script>
    
Attachment Table

Moment.js Time Format

 TokenOutput
MonthM1 2 ... 11 12
Mo1st 2nd ... 11th 12th
MM01 02 ... 11 12
MMMJan Feb ... Nov Dec
MMMMJanuary February ... November December
QuarterQ1 2 3 4
Qo1st 2nd 3rd 4th
Day of MonthD1 2 ... 30 31
Do1st 2nd ... 30th 31st
DD01 02 ... 30 31
Day of YearDDD1 2 ... 364 365
DDDo1st 2nd ... 364th 365th
DDDD001 002 ... 364 365
Day of Weekd0 1 ... 5 6
do0th 1st ... 5th 6th
ddSu Mo ... Fr Sa
dddSun Mon ... Fri Sat
ddddSunday Monday ... Friday Saturday
Day of Week (Locale)e0 1 ... 5 6
Day of Week (ISO)E1 2 ... 6 7
Week of Yearw1 2 ... 52 53
wo1st 2nd ... 52nd 53rd
ww01 02 ... 52 53
Week of Year (ISO)W1 2 ... 52 53
Wo1st 2nd ... 52nd 53rd
WW01 02 ... 52 53
YearYY70 71 ... 29 30
YYYY1970 1971 ... 2029 2030
Y1970 1971 ... 9999 +10000 +10001
Note: This complies with the ISO 8601 standard for dates past the year 9999
Week Yeargg70 71 ... 29 30
gggg1970 1971 ... 2029 2030
Week Year (ISO)GG70 71 ... 29 30
GGGG1970 1971 ... 2029 2030
AM/PMAAM PM
aam pm
HourH0 1 ... 22 23
HH00 01 ... 22 23
h1 2 ... 11 12
hh01 02 ... 11 12
k1 2 ... 23 24
kk01 02 ... 23 24
Minutem0 1 ... 58 59
mm00 01 ... 58 59
Seconds0 1 ... 58 59
ss00 01 ... 58 59
Fractional SecondS0 1 ... 8 9
SS00 01 ... 98 99
SSS000 001 ... 998 999
SSSS ... SSSSSSSSS000[0..] 001[0..] ... 998[0..] 999[0..]
Time Zonez or zzEST CST ... MST PST
Note: as of 1.6.0, the z/zz format tokens have been deprecated from plain moment objects. Read more about it here. However, they do work if you are using a specific time zone with the moment-timezone addon.
Z-07:00 -06:00 ... +06:00 +07:00
ZZ-0700 -0600 ... +0600 +0700
Unix TimestampX1360013296
Unix Millisecond Timestampx1360013296123
Localized formats
TimeLT8:30 PM
Time with secondsLTS8:30:25 PM
Month numeral, day of month, yearL09/04/1986
l9/4/1986
Month name, day of month, yearLLSeptember 4, 1986
llSep 4, 1986
Month name, day of month, year, timeLLLSeptember 4, 1986 8:30 PM
lllSep 4, 1986 8:30 PM
Month name, day of month, day of week, year, timeLLLLThursday, September 4, 1986 8:30 PM
llllThu, Sep 4, 1986 8:30 PM
Related

Source Code

<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- Add Moment.js, If change language, add language file » https://cdnjs.com/libraries/moment.js -->
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.20.1/moment.min.js"></script>
    <title>Moment.js</title>
    <style>
        .result {
            display: block;
            padding: .5em;
            width: 100%;
            max-width: 640px;
            margin-right: 20px;
            box-sizing: border-box;
        }
        section.note{
            max-width: 640px;
            box-sizing: border-box;
        }
    </style>
</head>
<body>
    <header>
        <h1 class="dlw-title">Moment.js</h1>
        <p class="dlw-description">Moment.js is a javascript that processes and displays date and time.</p>
    </header>
    <section>
        <h2 class="dlw-subtitle">[1] Format Dates</h2>
        <script>
            // Perform processing every second for real time reflection.
            function showDate01() {
                var m = moment();
                // Default
                document.getElementById("date01-1").value = m.format();
                // Month
                document.getElementById("date01-2").value = m.format('M | Mo | MM | MMM | MMMM');
                // Quarter
                document.getElementById("date01-3").value = m.format('Q | Qo');
                // Day of Month
                document.getElementById("date01-4").value = m.format('D | Do | DD');
                // Day of Year
                document.getElementById("date01-5").value = m.format('DDD | DDDo | DDDD');
                // Day of Week
                document.getElementById("date01-6").value = m.format('d | do | dd | ddd | dddd');
                // Year
                document.getElementById("date01-7").value = m.format('YY | YYYY');
                // AM/PM
                document.getElementById("date01-8").value = m.format('A | a');
                // Hour
                document.getElementById("date01-9").value = m.format('H | HH | h | hh | k | kk');
                // Minute
                document.getElementById("date01-10").value = m.format('m | mm');
                // Second
                document.getElementById("date01-11").value = m.format('s | ss');
                // Combination
                document.getElementById("date01-12").value = m.format('MMMM Do YYYY | h:mm:ss a');
            }
            setInterval('showDate01()', 1000);
        </script>
        <h3 class="dlw-lead">Default</h3>
        <input class="result" type="text" id="date01-1">
        <h3 class="dlw-lead">Month</h3>
        <input class="result" type="text" id="date01-2">
        <h3 class="dlw-lead">Quarter</h3>
        <input class="result" type="text" id="date01-3">
        <h3 class="dlw-lead">Day of Month</h3>
        <input class="result" type="text" id="date01-4">
        <h3 class="dlw-lead">Day of Year</h3>
        <input class="result" type="text" id="date01-5">
        <h3 class="dlw-lead">Day of Week</h3>
        <input class="result" type="text" id="date01-6">
        <h3 class="dlw-lead">Year</h3>
        <input class="result" type="text" id="date01-7">
        <h3 class="dlw-lead">AM/PM</h3>
        <input class="result" type="text" id="date01-8">
        <h3 class="dlw-lead">Hour</h3>
        <input class="result" type="text" id="date01-9">
        <h3 class="dlw-lead">Minute</h3>
        <input class="result" type="text" id="date01-10">
        <h3 class="dlw-lead">Second</h3>
        <input class="result" type="text" id="date01-11">
        <h3 class="dlw-lead">Combination</h3>
        <input class="result" type="text" id="date01-12">
    </section>
    <section>
        <h2 class="dlw-subtitle">[2] Localized formats</h2>
        <script>
            // Perform processing every second for real time reflection.
            function showDate02() {
                var m = moment();
                // Time
                document.getElementById("date02-1").value = m.format('LT');
                // Time with seconds
                document.getElementById("date02-2").value = m.format('LTS');
                // Month numeral, day of month, year
                document.getElementById("date02-3").value = m.format('L | l');
                // Month name, day of month, year
                document.getElementById("date02-4").value = m.format('LL | ll');
                // Month name, day of month, year, time
                document.getElementById("date02-5").value = m.format('LLL | lll');
                // Month name, day of month, day of week, year, time
                document.getElementById("date02-6").value = m.format('LLLL | llll');
            }
            setInterval('showDate02()', 1000);
        </script>
        <h3 class="dlw-lead">Time</h3>
        <input class="result" type="text" id="date02-1">
        <h3 class="dlw-lead">Time with seconds</h3>
        <input class="result" type="text" id="date02-2">
        <h3 class="dlw-lead">Month numeral, day of month, year</h3>
        <input class="result" type="text" id="date02-3">
        <h3 class="dlw-lead">Month name, day of month, year</h3>
        <input class="result" type="text" id="date02-4">
        <h3 class="dlw-lead">Month name, day of month, year, time</h3>
        <input class="result" type="text" id="date02-5">
        <h3 class="dlw-lead">Month name, day of month, day of week, year, time</h3>
        <input class="result" type="text" id="date02-6">
    </section>
    <section>
        <h2 class="dlw-subtitle">[3] Relative elapsed time</h2>
        <script>
            window.addEventListener('load', function () {
                // Relative elapsed time on specified date from now (fromNow)
                document.getElementById("date03-1").value = moment("2010-4-30").fromNow();
                // Relative elapsed time on specified date from another specified date (from)
                document.getElementById("date03-2").value = moment("2010-4-30").from("2015-3-1");
                // Relative elapsed time on now from specified date (toNow)
                document.getElementById("date03-3").value = moment("2010-4-30").toNow();
                // Relative elapsed time on specified date from another specified date (to)
                document.getElementById("date03-4").value = moment("2010-4-30").to("2015-3-1");
                // Today's relative elapsed time (startOf)
                document.getElementById("date03-5").value = moment().startOf('day').fromNow();
                // Today's relative end time (endOf)
                document.getElementById("date03-6").value = moment().endOf('day').fromNow();
            })
        </script>
        <h3 class="dlw-lead">Relative elapsed time on specified date from now (fromNow)</h3>
        <input class="result" type="text" id="date03-1">
        <h3 class="dlw-lead">Relative elapsed time on specified date from another specified date (from)</h3>
        <input class="result" type="text" id="date03-2">
        <h3 class="dlw-lead">Relative elapsed time on now from specified date (toNow)</h3>
        <input class="result" type="text" id="date03-3">
        <h3 class="dlw-lead">Relative elapsed time on specified date from another specified date (to)</h3>
        <input class="result" type="text" id="date03-4">
        <h3 class="dlw-lead">Today's relative elapsed time (startOf)</h3>
        <input class="result" type="text" id="date03-5">
        <h3 class="dlw-lead">Today's relative end time (endOf)</h3>
        <input class="result" type="text" id="date03-6">
    </section>
    <section>
        <h2 class="dlw-subtitle">[4] Calendar Time </h2>
        <script>
            window.addEventListener('load', function () {
                // Calendar Format
                document.getElementById("date04-1").value = moment().calendar();
                // 10 days ago
                document.getElementById("date04-2").value = moment().subtract(10, 'days').calendar();
                // 6 days ago
                document.getElementById("date04-3").value = moment().subtract(6, 'days').calendar();
                // Yesterday
                document.getElementById("date04-4").value = moment().subtract(1, 'days').calendar();
                // Tommorow
                document.getElementById("date04-5").value = moment().add(1, 'days').calendar();
                // 6 days later
                document.getElementById("date04-6").value = moment().add(6, 'days').calendar();
                // 10 days later
                document.getElementById("date04-7").value = moment().add(10, 'days').calendar();
            })
        </script>
        <h3 class="dlw-lead">Calendar Format</h3>
        <input class="result" type="text" id="date04-1">
        <h3 class="dlw-lead">10 days ago</h3>
        <input class="result" type="text" id="date04-2">
        <h3 class="dlw-lead">6 days ago</h3>
        <input class="result" type="text" id="date04-3">
        <h3 class="dlw-lead">Yesterday</h3>
        <input class="result" type="text" id="date04-4">
        <h3 class="dlw-lead">Tommorow</h3>
        <input class="result" type="text" id="date04-5">
        <h3 class="dlw-lead">6 days later</h3>
        <input class="result" type="text" id="date04-6">
        <h3 class="dlw-lead">10 days later</h3>
        <input class="result" type="text" id="date04-7">
    </section>
    <section>
        <h2 class="dlw-subtitle">[5] Difference </h2>
        <script>
            window.addEventListener('load', function () {
                // Number of days from the specified date to today
                document.getElementById("date05-1").value = moment().diff(moment("2016-12-31"), 'days');
                // Number of days from the specified date to another specified date
                document.getElementById("date05-2").value = moment("2017-6-15").diff(moment("2016-12-31"), 'days');
            })
        </script>
        <h3 class="dlw-lead">Number of days from the specified date to today</h3>
        <input class="result" type="text" id="date05-1">
        <h3 class="dlw-lead">Number of days from the specified date to another specified date</h3>
        <input class="result" type="text" id="date05-2">
    </section>
</body>
</html>

Comment

Search

Style Design
Text Style DesignCSS

Here, design samples of various effects to text are posted.

Headline (Heading) Style DesignCSS

The headline is the text indicating the nature of the article below it.
Here, design samples of headline using style sheets are posted.

OL (Ordered List) Style DesignCSS

The HTML <ol> element represents an ordered list of items.
Here, design samples of ol using style sheets are posted.

HR (Separator Line) Style DesignCSS

The HTML <hr> element represents a thematic break between paragraph-level elements.
Here, design samples of hr using style sheets are posted.

Box Shadow Style DesignCSS

The box-shadow CSS property is used to add shadow effects around an element's frame.
Here, design samples of box-shadow property using style sheets are posted.

Layout
How to specify a breakpoint and switch imagesJS

Using <picture> and srcset, it is a method of switching images according to screen size. It also corresponds to retina.
In this example, Picturefill is added for IE.

Grid LayoutCSS

Grid is the value of the CSS display property.
Here, layout samples of grid property are posted.

FlexCSS

Flex is the value of the CSS display property.

Link & Button
Bootstrap ButtonCSS

It is a standard button design of Bootstrap Framework.

Hover.cssCSS

Hover.css is a style-sheet collection of hover effects.

Button.cssCSS

Button.css is collection of CSS3 button animations.

Card
Bootstrap CardCSS

It is a standard Card design of Bootstrap Framework.

Text
Arctext.jsjQuery

Arctext.js is a jQuery plugin that causes a string to curve along a specified circle radius.

Lettering.jsjQuery

Lettering.js is a jQuery plugin that encloses a specified character string with one character, one word, one column by <span> tag.

Textillate.jsjQuery

Textillate.js is a jQuery plugin that adds In / Out animation effects to text.

FitText.jsjQuery

FitText.js is jQuery plugin that fits the font size according to the width of the parent element.

Media
FeedEkjQuery

FeedEk is a jQuery plugin that parses RSS and Atom feeds and displays them.

YouTube Embed

Introduction of various embedment methods of YouTube.

FitVids.jsjQuery

FitVids is a jQuery plug-in that converts YouTube videos embedded with iframe into responsive.

xZoomjQuery

xZoom is a jQuery plug-in that shows a zoom preview of the image.
It is possible to customize the preview position and zoom.

Instagram.cssCSS

Instagram.css is a stylesheet set that filters photos like instagram.

Date
Moment.jsJS

Moment.js is a javascript that processes and displays date and time.

Bootstrap Material DatePickerjQuery

Bootstrap Material DatePicker is jQuery data picker plugin using Moment.js.

Table
MultifilterjQuery

Multifilter is jQuery Table Filtering Plugin.

Flex TableCSS

Responsive table using "display: flex;".
Not supported for rowspan.

Grid TableCSS

Responsive table using "display: grid;".
Not supported for rowspan.

Bootstrap TableCSS

It is a standard Table design of Bootstrap Framework.

Form
jQuery Mask PluginjQuery

jQuery Mask Plugin is jQuery plugin that make mask (validation) on form field.

Select2 #1. Basic SettingjQuery

Select2 is a jquery plugin that makes select form more advanced.
Here is the basic usage of Select2.

jQuery SearcherjQuery

jQuery Searcher is jQuery search/filtering plugin that supports various markups.

Slider
Bootstrap CarouseljQuery

It is a standard Carousel of Bootstrap Framework.

FlexSlider #1. Single SliderjQuery

FlexSlider is responsive jQuery slider plugin.
Here, basic single slider setting of Flexslider are posted.

FlexSlider #2. Carousel SliderjQuery

FlexSlider is responsive jQuery slider plugin.
Here, basic carousel slider setting of Flexslider are posted.

slick #1. Single SliderjQuery

slick is responsive jQuery slider plugin.
Here, basic single slider setting of slick are posted.

slick #2. Carousel SliderjQuery

slick is responsive jQuery slider plugin.
Here, carousel slider setting of slick are posted.

Lightbox
fancyBox #1. basic image lightboxjQuery

fancyBox is jQuery lightbox plugin.
Here, basic image lightbox setting of fancyBox are posted.

fancyBox #2. media lightboxjQuery

fancyBox is jQuery lightbox plugin.
Here, YouTube, Vimeo, Instagram, Google Maps, inline HTML, iframe lightbox setting of fancyBox are posted.

Magnific Popup #1. basic image lightboxjQuery

Magnific Popup is jQuery lightbox plugin.
Here, basic image lightbox setting of Magnific Popup are posted.

Magnific Popup #2. media lightboxjQuery

Magnific Popup is jQuery lightbox plugin.
Here, YouTube, Vimeo, Google Maps, inline HTML lightbox setting of Magnific Popup are posted.

Magnific Popup #3. CSS3-based animation effectsjQuery

Since Magnific Popup does not incorporate animation effects by standard, you need to set it yourself.
Here we summarize the CSS3-based animation settings.

Navigation
animsitionjQuery

animsition is a jQuery plugin that adds an in/out animation effect at the time of page transition.

GreedyNavjQuery

GreedyNav is a responsive navigation menu using jQuery which switches over the items that protruded when the screen was scaled down to dropdown.

GridTabjQuery

GridTab is a lightweight jQuery plugin to create grid based responsive tabs.

jQuery.NiceScrolljQuery

jQuery.NiceScroll is a jQuery plugin that extends scroll display and functions.

metisMenujQuery

metisMenu is a jQuery plugin that expands vertical and vertical menus.

fullPage.js #1. basic fullscreen scrollingjQuery

fullPage.js is jQuery Fullscreen Scrolling plugin.
Here, basic fullscreen scrolling of fullPage.js are posted.

fullPage.js #2. fullscreen scrolling with menujQuery

fullPage.js is jQuery Fullscreen Scrolling plugin.
Here, navigation menu is displayed..

Offside.js #1. Basic Off-canvasJS

Offside.js is a JavaScript kit that expands off-canvas.
This is a sample where the left side off-canvas expands.

Offside.js #2. Multiple Off-canvasJS

Offside.js is a JavaScript kit that expands off-canvas.
This is a sample that expands multiple off-canvases.

Filterizr #1. Basic FilteringjQuery

Filterizr is a jQuery plugin that sorts, shuffles, searches for the items in the container.
This is a basic sample without setting options.

Filterizr #2. Advanced FilteringjQuery

Filterizr is a jQuery plugin that sorts, shuffles, searches for the items in the container.
This is a sample of more advanced setting of Filterizr.

Animation
animsitionjQuery

animsition is a jQuery plugin that adds an in/out animation effect at the time of page transition.

Textillate.jsjQuery

Textillate.js is a jQuery plugin that adds In / Out animation effects to text.

ScrollajQuery

Scrolla is jQuery scroll animation plugin.

Hover.cssCSS

Hover.css is a style-sheet collection of hover effects.

Animate.cssCSS

Animate.css is a style-sheet collection of animation effects.

jQuery Easing PluginjQuery

jQuery Easing Plugin is a plugin to extend the easing (animation effect) of jQuery.
The easing of element is posted.

Background
fullPage.js #1. basic fullscreen scrollingjQuery

fullPage.js is jQuery Fullscreen Scrolling plugin.
Here, basic fullscreen scrolling of fullPage.js are posted.

fullPage.js #2. fullscreen scrolling with menujQuery

fullPage.js is jQuery Fullscreen Scrolling plugin.
Here, navigation menu is displayed..

jquery.mb.YTPlayerjQuery

jQuery.mb.YTPlayer is jQuery Background player plugin.

Modal / Tooltip
Hint.cssCSS

Hint.css is a style sheet set for tooltip.
You can display tooltip just by adding class name.

ProtipjQuery

Protip is a jQuery plugin that generates tooltips.
Set the position, size, etc. of the tooltip only with data attribute.

Social
Framework
Bootstrap CarouseljQuery

It is a standard Carousel of Bootstrap Framework.

Bootstrap CardCSS

It is a standard Card design of Bootstrap Framework.

Bootstrap ButtonCSS

It is a standard button design of Bootstrap Framework.

Bootstrap TableCSS

It is a standard Table design of Bootstrap Framework.

Cheat Sheet
HTML5 Cheat Sheet

HTML5 Cheat Sheet by Make A Website Hub

CSS3 Cheat Sheet

CSS3 Cheat Sheet by Smashing Magazine

Visual Studio Code Keyboard Shortcuts

This is the Visual Studio Code default keyboard shortcut list.

GreenSock Cheat Sheet

Cheese sheet of TweenMAX, TweenLite, TimelineLite, TimelineMax by GreenSock.

Other
Google Search

On this page you can search for codes collectively.

Design News

It is a news feed about design.