moment.js 日本語表示

In this example below you will see how to do a moment.js 日本語表示 with some HTML / CSS and Javascript

Thumbnail
This awesome code was written by moonglows76, you can see more from this user in the personal repository.
You can find the original code on Codepen.io
Copyright moonglows76 ©

Technologies

  • HTML
  • CSS
  • JavaScript
<!DOCTYPE html>
<html lang="en" >

<head>
  <meta charset="UTF-8">
  <title>moment.js 日本語表示</title>
  
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css">

  
      <link rel="stylesheet" href="css/style.css">

  
</head>

<body>

  <div id="now_jpn"></div>
<div id="now_pst"></div>
  <script src='https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.6/moment.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.6/locale/ja.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js'></script>

  

    <script  src="js/index.js"></script>




</body>

</html>

/*Downloaded from https://www.codeseek.co/moonglows76/momentjs-andx65e5andx672candx8a9eandx8868andx793a-QQOQVR */
div {
  line-height: 2;
}

/*Downloaded from https://www.codeseek.co/moonglows76/momentjs-andx65e5andx672candx8a9eandx8868andx793a-QQOQVR */
let now_jpn = moment();
let nowWork = new Date();
let nowDay = nowWork.getDay();
let now_jpn_fix = "日本時間 " + now_jpn.add(7 - nowDay,"days").format("YYYY年MM月DD日(ddd) HH:mm:ss");

// 米国太平洋時間(PST)
let now_pst = now_jpn.add(-17, "hours"); // 日本時間から17時間を引く
let now_pst_fix = "米国太平洋時間 " + now_pst.format("YYYY年MM月DD日(ddd) HH:mm:ss");

$('#now_jpn').text(now_jpn_fix);
$('#now_pst').text(now_pst_fix);

Comments