Skip to content

Instantly share code, notes, and snippets.

@ogaty
Last active July 19, 2023 04:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ogaty/7802ac136a35d26cacc02e97a9c02e1e to your computer and use it in GitHub Desktop.
Save ogaty/7802ac136a35d26cacc02e97a9c02e1e to your computer and use it in GitHub Desktop.
javascript datetime luxon

moment.jsよりも分かりやすい

https://moment.github.io/luxon/#/install

<script src="https://cdn.jsdelivr.net/npm/luxon@3.0.4/build/global/luxon.min.js"></script>

初期登録

var DateTime = luxon.DateTime;

後はnew DateTimeで

d.year.toFormat('yyyy年MM月dd日');

d.plus({day: 1})
d.minus({day: 1})

d.set({weekday: 5}) // friday
xxx.weekdayLong // 日本語で金曜日
xxx.setLocale('en').weekdayLong // Friday

これいいね

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment