# 普通用法

点击查看代码
import moment from "moment";

// Relative Time
moment("20111031", "YYYYMMDD").fromNow(); // 9 years ago
moment("20120620", "YYYYMMDD").fromNow(); // 9 years ago
moment().startOf('day').fromNow();        // 15 hours ago
moment().endOf('day').fromNow();          // in 9 hours
moment().startOf('hour').fromNow();       // a few seconds ago

// Calendar Time
moment().subtract(10, 'days').calendar(); // 03/23/2021
moment().subtract(6, 'days').calendar();  // Last Saturday at 2:59 PM
moment().subtract(3, 'days').calendar();  // Last Tuesday at 2:59 PM
moment().subtract(1, 'days').calendar();  // Yesterday at 2:59 PM
moment().calendar();                      // Today at 2:59 PM
moment().add(1, 'days').calendar();       // Tomorrow at 2:59 PM
moment().add(3, 'days').calendar();       // Monday at 2:59 PM
moment().add(10, 'days').calendar();      // 04/12/2021