momentjs的使用

时间:2023-03-09 22:06:48
momentjs的使用

一、脚本引用

    <script src="~/Scripts/moment.js"></script>
<script src="~/Scripts/moment-with-locales.js"></script>

二、国际化,设置为简体中文,中文的星期是以星期一开始

    <script>
moment.locale("zh-cn");
</script>

下面就可以开始使用moment处理时间了,常用的方法:

格式化当前时间:

momentjs的使用

解析时间:

momentjs的使用

获取本日、本周、本月的时间范围:

本日:

momentjs的使用

本周:

momentjs的使用

本月:

momentjs的使用