Moment.js Test
HTML
<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>
<button onclick="showJpnTime()">日本時間</button>
<button onclick="showPstTime()">米国太平洋時間(PST)</button>
<button onclick="myfunc()">
myfunc
</button>
JavaScript
// moment.jsの外部ライブラリを2つ読み込んでます
// ← 左の「External Resources」参照
// 日本時間
function showJpnTime() {
var now_jpn = moment();
alert("日本時間 " + now_jpn.format("YYYY年MM月DD日(ddd) HH:mm:ss"));
}
// 米国太平洋時間(PST)
function showPstTime() {
var now_pst = moment();
var now_pst = now_pst.add(-17, "hours");
alert("米国太平洋時間 " + now_pst.format("YYYY年MM月DD日(ddd) HH:mm:ss"));
}
function myfunc(){
let tomorrow = moment().add(1, 'd');
alert(moment().calendar(tomorrow));
alert(moment().calendar(tomorrow,{
sameDay: '[きょう]',
nextDay: '[あす]',
nextWeek: 'dddd',
lastDay: 'きのう ah時m分',
lastWeek: '[前の] dddd',
sameElse: 'YYYY年MM月DD日'
}));
// alert(moment().from('2019-01-18 00:00:00'));
}