当前位置:网站首页>Moment get week, month, quarter, year
Moment get week, month, quarter, year
2022-07-23 10:13:00 【weixin_ thirty-eight million six hundred and seventy-three thou】
Get week
moment().week();// Current week (number)
moment().startOf('isoWeek');// Start time of current week
moment().endOf('isoWeek');// End of current week
moment().add(-1, 'W');// Last week
moment().add(1, 'W');// next week
// Note last week -1 next week +1 And so on month 、 quarter 、 Same as year
Get the month
moment().month();// The current month -1(number)
moment().startOf('month');// Start time of current month
moment().endOf('month');// End time of current month
moment().add(-1, 'M');// Last month
moment().add(1, 'M');// Next month
Get Quarterly
moment().quarter();// The current quarter (number)
moment().startOf('quarters');// Start time of the quarter
moment().endOf('quarters');// End time of the quarter
moment().add(-1, 'Q');// the previous quarter
moment().add(1, 'Q');// Next quarter
Get the timestamp of the start and end of the currently selected quarter
quarter(e){
//e Currently selected quarter
let nowQuarter = moment().quarter();
// If quarter is not selected Get the current quarter by default
e = e || nowQuarter
let monthArray = [1,4,7,10];
// Get the month corresponding to the quarter
let month = monthArray[e - 1];
let m = moment().month(month).date(5);
this.form.startTime = m.startOf('quarters').toDate().getTime();
this.form.endTime = m.endOf('quarters').toDate().getTime();
}
Year of acquisition
moment().year();// The current year (number)
moment().startOf('year');// Start time of the year
moment().endOf('year');// End time of the year
moment().add(-1, 'y');// The previous year
moment().add(1, 'y');// Next year
Is it a leap year
moment().isLeapYear();
# true
moment([2001]).isLeapYear()
# false
Get the day of the week the first day of the month
# Used to set the day of the week , Sunday is 0、 Saturday is 6
moment().startOf('month').day()
Before acquisition n God / after n God
moment().add(7, 'days');
moment().subtract(7, 'days')
边栏推荐
- leetcode-99.恢复二叉搜索树
- [notes on the practice of node middle tier (I)] -- building the project framework
- 在线问题反馈模块实战(十一):实现图片下载功能
- This tool complements the last kilometer of JMeter performance analysis
- spark分区算子partitionBy、coalesce、repartition
- How is it safe to open an account for Haitong Securities' exchange fund
- 【300+精选大厂面试题持续分享】大数据运维尖刀面试题专栏(七)
- Learn and understand Architecture Design from business development
- 南京银行提前批金融科技岗
- 数组中的逆序对
猜你喜欢
随机推荐
The gospel of small and medium-sized enterprises is coming! Jnpf is becoming popular, helping business digital upgrading
How is it safe to open an account for Haitong Securities' exchange fund
Android开发学习日记--内容提供者(跨应用间的数据库修改)
C语言——几道C语言经典习题
华泰证券开户安全吗是真的吗,是正规的吧
时间序列-第三方库:tsfresh【特征提取、特征选择】
射频电路循证设计
1.赋值语句
【C语言基础】15 位运算
【南瓜书ML】(task3)决策树(更新ing)
南京银行提前批金融科技岗
数据库安全性和数据的完整性
这个工具,补齐了 JMeter性能分析最后一公里短板
Click position and click offset of airtest script
This tool complements the last kilometer of JMeter performance analysis
C语言文件操作
用现代化的开发方法和思维,打跑遗留系统“拦路虎”
逆向理论知识1
中小企业的福音来咯!JNPF渐火,助力业务数字化升级
【循环语句】









