- MomentJS 教程
- MomentJS - 主頁
- MomentJS - 概述
- MomentJS - 環境設定
- MomentJS - 介紹
- MomentJS - 解析日期和時間
- MomentJS - 日期驗證
- MomentJS - 獲取器/設定器
- 操作日期和時間
- 格式化日期和時間
- MomentJS - 日期查詢
- MomentJS - 國際化
- MomentJS - 自定義
- MomentJS - 持續時間
- MomentJS - 實用工具
- MomentJS - 外掛
- MomentJS - 示例
- MomentJS 有用資源
- MomentJS - 快速指南
- MomentJS - 有用資源
- MomentJS - 討論
MomentJS - 至今的時間
此方法會顯示給定日期到現在的時段長度。
語法
moment().toNow(); moment().toNow(Boolean);
示例
var a = moment([2015, 3, 15]).toNow();
輸出
如果要刪除字首,請使用 true 與 toNow() 結合使用,如下所示 −
示例
var a = moment([1995, 3, 15]).toNow(true);
輸出
momentjs_formatting_date_and_time.htm
廣告