- MomentJS 教程
- MomentJS - 首頁
- MomentJS - 概覽
- MomentJS - 環境設定
- MomentJS - 簡介
- MomentJS - 解析日期和時間
- MomentJS - 日期驗證
- MomentJS - 獲取器/設定器
- 操作日期和時間
- 格式化日期和時間
- MomentJS - 日期查詢
- MomentJS - 國際化
- MomentJS - 自適應
- MomentJS - 持續時間
- MomentJS - 實用工具
- MomentJS - 外掛
- MomentJS - 示例
- MomentJS 有用資源
- MomentJS - 快速指南
- MomentJS - 有用資源
- MomentJS - 討論
MomentJS - 日曆時間
此方法顯示與給定參考時間和日曆時間的時差。
語法
moment().calendar(); moment().calendar(referenceTime); moment().calendar(referenceTime, formats);
例 1
var changeddate = moment().calendar();
輸出
例 2
我們在前一章討論了連結方法,因此我們可以將加/減方法與 moment 一起使用以獲取日曆值,如下所示 −
var changeddate = moment().add(24, 'h').calendar();
輸出
例 3
var changeddate = moment().subtract(24, 'h').calendar();
輸出
momentjs_formatting_date_and_time.htm
廣告