css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

              <h1>Moment.jsデモ Ver: 2.22.2</h1>
<div id="main"></div>
  font-family: sans-serif;
  padding: 1em 2em;
  background-color: #222;
  color: #fff;
  padding-left: 1em;
  border-left: 10px solid #ddd;
  border-bottom: 1px solid #ddd;
  line-height: 2em;
  margin: 1.2em;
  padding-left: 2em;
  border-bottom: 1px solid #888;
  margin: 1.2em;
  margin-top: 2em;
  padding-left: 1em;
  font-size: 1.4em;
  border-left: 10px solid #ddd;
    font-size: 1.2em;
    border-left: 10px solid #888;

              // ------------------
// HTML表示用関数
// ------------------
function showDisplay(str1, str2){
  $("#main").append('<div class="con"><p class="des">'+ str1 +'</p><p class="content">'+ str2 +'</p></div>');
function separate(str, i){
  if(i == 1){ // mini Separation
    $("#main").append('<div class="separate min">'+ str +'</div>');
  }else if(i == 2) // Separation{
    $("#main").append('<div class="separate def">'+ str +'</div>');

// ------------------
// 書式サポート: 
// 英語圏でよく使用される書式はほとんどサポートされている
// それ以外の書式は基本サポートされていないらしい・使用するには自分でフォーマットを指定する必要が
// 参考: https://momentjs.com/docs/#/parsing/string-format/
separate("書式サポート", 2);
showDisplay("現在時刻: ", moment().format());
showDisplay("日時指定: ", moment("1995-12-25").format());
showDisplay("日時+フォーマット指定: ", moment("2018年09月18日 10時58分33秒", "YYYY年MM月DD日 HH時mm分ss秒").format());
// ※UnixTime(1970年1月1日0時0分からの経過秒数で日時を表す)
showDisplay("UnixTime指定: ", moment(new Date().getTime()).format());
separate("Momentオブジェクトかどうか判別", 1);
showDisplay("\"2013-02-08 24:00:00.000\" は日時かどうか: ", moment("2013-02-08 24:00:00.000").isValid());
showDisplay("\"not a real date\" は日時かどうか: ", moment("not a real date").isValid());

// ------------------
// Timezone: 
// moment.jsプラグイン「Moment Timezone」追加で、
// 文字列を使用してタイムゾーン変更やフォーマットが可能に
// ex. Asia/Tokyo, JST
// https://momentjs.com/timezone/
separate("Timezoneプラグイン", 2);
var a = moment.tz("2013-11-18 11:55", "Asia/Tokyo");
var b = moment.tz("2013-11-18 11:55", "America/Toronto");
showDisplay("東京の日時: ", a.format("YYYY-MM-DD HH:mm:ssZ")); // 2013-11-18T11:55:00+08:00
showDisplay("トロントの日時: ", b.format("YYYY-MM-DD HH:mm:ssZ")); // 2013-11-18T11:55:00-05:00

// ------------------
// format関数: momentオブジェクトを指定したフォーマット形式に変更
// よく使われるフォーマットにはプリセットが…下記のように使う
separate("format関数のプリセット", 2);
showDisplay("locate: ", moment.locale());         // js
showDisplay("LT: ", moment().format('LT'));   // 18.26
showDisplay("LTS: ", moment().format('LTS'));  // 18.26.52
showDisplay("L: ", moment().format('L'));    // 18/09/2018
showDisplay("l: ", moment().format('l'));    // 18/9/2018
showDisplay("LL: ", moment().format('LL'));   // 18 September 2018
showDisplay("ll: ", moment().format('ll'));   // 18 Sep 2018
showDisplay("LLL: ", moment().format('LLL'));  // 18 September 2018 pukul 18.26
showDisplay("lll: ", moment().format('lll'));  // 18 Sep 2018 pukul 18.26
showDisplay("LLL: ", moment().format('LLLL')); // Seloso, 18 September 2018 pukul 18.26
showDisplay("llll: ", moment().format('llll')); // Sel, 18 Sep 2018 pukul 18.27

// ------------------
// locateのアップデート
separate("locateのアップデート", 2);
moment.updateLocale("ja", {
  months: [
    "睦月", "如月", "弥生", "卯月", "皐月", "水無月",
    "文月", "葉月", "長月", "神無月", "霜月", "師走"
  monthsShort: [
    "睦", "如", "弥", "卯", "皐", "水無",
    "文", "葉", "長", "神無", "霜", "師"
showDisplay("現在時刻: ", moment().format("MMM"));
showDisplay("1ヶ月後: ", moment().add(1, "month").format("MMM"));
showDisplay("2ヶ月後: ", moment().add(2, "month").format("MMMM"));
showDisplay("3ヶ月後: ", moment().add(3, "month").format("MMMM"));

// ------------------
// 小ネタ: 
// Moment.jsでは data=日付/day=曜日 という考え方
// 確かにこれらの単語の意味も、date=日付/年月日と明確だが、day=日となっている…。
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................