当前位置: 首页 > news >正文

开发者门户网站是什么意思实事热点新闻事件

开发者门户网站是什么意思,实事热点新闻事件,wordpress仿盗,汕头服饰网站建设文章目录1. 初始化日期 / 时间2. 格式化日期 / 时间3. 加 / 减4. 获取某年某月的第一天或最后一天5. 获取星期几6. 获取毫秒数7. 获取时间差#xff08;默认输出的差值单位是毫秒#xff09;8. 获取时、分、秒9. 将毫秒转为时分秒10. 判断一个日期是否在另外一个日期之后 isA… 文章目录1. 初始化日期 / 时间2. 格式化日期 / 时间3. 加 / 减4. 获取某年某月的第一天或最后一天5. 获取星期几6. 获取毫秒数7. 获取时间差默认输出的差值单位是毫秒8. 获取时、分、秒9. 将毫秒转为时分秒10. 判断一个日期是否在另外一个日期之后 isAfter11. 判断一个日期是否在另外一个日期之前 isBefore12. 判断两个日期是否相同 isSame13. 判断一个日期是否在两个日期之间 isBetweenDay.js官方文档1. 初始化日期 / 时间 dayjs().format(YYYY-MM-DD); // 初始化日期 dayjs().format(YYYY-MM-DD HH:mm:ss); // 初始化日期时间2. 格式化日期 / 时间 dayjs(value).format(YYYY-MM-DD); // 初始化日期 dayjs(value).format(YYYY-MM-DD HH:mm:ss); // 初始化日期时间3. 加 / 减 dayjs().add / dayjs().subtract 代表在当前时间上去加减 dayjs(value).add / dayjs(value).subtract 代表在指定时间value上去加减 dayjs().add(7, day).format(YYYY-MM-DD); // 2022-04-27 今天2022-04-20加上7天 dayjs().add(1, month).format(YYYY-MM-DD); // 2022-05-20 今天2022-04-20加上一月dayjs().subtract(2, year).format(YYYY-MM-DD); // 2020-05-20 今天2022-04-20减去2年 dayjs().subtract(2, hour).format(YYYY-MM-DD HH:mm:ss); // 2022-04-20 14:03:39 今天现在2022-04-20 16:03:39减去2小时所有可用单位列表 4. 获取某年某月的第一天或最后一天 获取某年某月的第一天 dayjs().startOf(year).format(YYYY-MM-DD HH:mm:ss) // 2022-01-01 00:00:00 第一天格式化出来的时分秒都是0 dayjs().startOf(month).format(YYYY-MM-DD) // 2022-04-01获取某年某月的最后一天 dayjs().endOf(year).format(YYYY-MM-DD HH:mm:ss) // 2022-12-31 23:59:59 最后时间 格式化出来的时分秒是23:59:59 dayjs().endOf(month).format(YYYY-MM-DD) // 2022-04-305. 获取星期几 dayjs().day() : 返回0(星期日)到6(星期六)的数字 设置时也只能接受 0-6 的数字 dayjs().day(6).format(YYYY-MM-DD)获取最近周六的日期 2022-04-23 dayjs().day(0).format(YYYY-MM-DD)获取最近周日的日期 2022-04-176. 获取毫秒数 dayjs(2019-01-25).valueOf() 或 dayjs().valueOf()7. 获取时间差默认输出的差值单位是毫秒 dayjs(2019-01-25).diff(2018-06-05, month); // 7 dayjs(2019-01-25).diff(dayjs(2018-06-05), month); // 7所有可用输出单位列表 8. 获取时、分、秒 当前时间2022-04-20 16:55:55 以下大部分方法都会往前溢出如毫秒超过999将持续到秒秒超过59将持续到分这边情况在设置时特别突出 console.log(-----获取年, dayjs().year()); // 2022console.log(-----获取月, dayjs().month()); // 0到11的数字 3console.log(-----获取星期, dayjs().day()); // 0(星期日)到6(星期六)的数字 3console.log(-----获取天, dayjs().date()); // 1到31的数字 20console.log(-----获取小时, dayjs().hour()); // 0到23的数字 16console.log(-----获取分钟, dayjs().minute());// 0到59的数字 55console.log(-----获取秒, dayjs().second()); // 0到59的数字 55console.log(-----获取毫秒, dayjs().millisecond()); // 0到999的数字 333 9. 将毫秒转为时分秒 // 下面毫秒数代表2022-04-20 17:43:20 const timestr 1650447800731; // 毫秒值必须是number类型如果是string结果可能和你想的不一样 console.log(将毫秒转为年-月-日 时:分:秒, dayjs(timestr).format(YYYY-MM-DD HH:mm:ss)); console.log(获取年, dayjs(timestr).year()); // console.log(获取月, dayjs(timestr).month()); console.log(获取天, dayjs(timestr).date()); console.log(获取时, dayjs(timestr).hour()); console.log(获取分, dayjs(timestr).minute());注意这里 year()、month()、date()、hour()、minute()、second()、millisecond() 等方法均可使用 10. 判断一个日期是否在另外一个日期之后 isAfter // day.js 为 2022-04-20 console.log(isAfter, dayjs().isAfter(dayjs(2011-01-01))) // true console.log(isAfter, dayjs(2022-04-20).isAfter(dayjs(2022-04-21))) // false console.log(isAfter, dayjs(2022-04-20).isAfter(dayjs(2022-04-20))) // 相同也为false11. 判断一个日期是否在另外一个日期之前 isBefore // day.js 为 2022-04-20 console.log(isBefore, dayjs().isBefore(dayjs(2011-01-01))) // false console.log(isBefore, dayjs(2022-04-20).isBefore(dayjs(2022-04-21))) // true console.log(isBefore, dayjs(2022-04-20).isBefore(dayjs(2022-04-20))) // 日期相同时也为false12. 判断两个日期是否相同 isSame // day.js 为 2022-04-20 console.log(isSame, dayjs().isSame(dayjs(2011-01-01))) // false console.log(isSame, dayjs(2022-04-20).isSame(dayjs(2022-04-21))) // false console.log(isSame, dayjs(2022-04-20).isSame(dayjs(2022-04-20))) // true13. 判断一个日期是否在两个日期之间 isBetween 注意: 此功能依赖IsBetween插件 此处也将演示如何使用 Day.js 的插件 import dayjs from dayjs // 引入dayjs import isBetween from dayjs/plugin/isBetween // 引入相关插件created() {dayjs.extend(isBetween); // 挂载插件// 使用插件console.log(isBetween, dayjs(2010-10-20).isBetween(2010-10-19, dayjs(2010-10-25)) ) }Day.js 里面有 相同或之前 IsSameOrBefore 和 相同或之后 IsSameOrAfter的方法可根据实际需求取用但这两个方法需要依赖相应的插件 注意 isAfter、isBefore、isSame、IsBetween 默认都是通过将日期转为milliseconds去比较的所以这两个方法有第二个参数。即指定比较的粒度 console.log(isBefore, dayjs(2022-04-20).isBefore(2015-01-01, year))所有可用单位列表
http://www.yutouwan.com/news/373524/

相关文章:

  • 网站流量分析报告河南网站怎么备案
  • 网站建设互联建设大型的企业网站费用
  • 做下一个盗版小说网站wordpress个人博客安装
  • 我的世界电影怎么做的视频网站怎样做自己的网络平台
  • 专业做视频的网站有哪些内容成都网站建设培训
  • 云南住建局和城乡建设报考网站wordpress文本组件使用方法
  • 鹰潭市住房和城乡建设局网站太原建站建设
  • 阀门行业网站怎么做石家庄做网站建设
  • 计算机网站开发课本河南平台网站建设
  • 六安电子商务网站建设汽车网站建设
  • 做泵阀生意到哪个网站学院网站建设投标
  • 太仓广告设计公司网站dz网站制作
  • 在线做任务的网站平东网站建设
  • 带做网站绿标东莞 手机网站制作
  • 三只松鼠网站开发模板励销云
  • 傻瓜式建网站网站后台 清理缓存
  • 网站建设服务公司开源网站代码
  • 网页休闲游戏网站论坛网站如何备案
  • 网站后台管理js建筑企业培训课程
  • 门户网站做wordpress多页面主题
  • 全屏类网站建设为什么国外网站有时打不开
  • 邵阳县网站建设公司沙河网站建设公司免费网页托管
  • 网站建设中间件收费江阴网站制作
  • 世界杯网站建设国内精美网站
  • 做网站建设多少钱如何做网站解析
  • 福田网站建设龙岗网站建设罗湖网站建设罗湖网站建设建设网站是什么职位
  • 微信公众号与网站绑定汕头汽配网站建设
  • 企业网站安全建设方案网站建设腾讯云与阿里云
  • 英文企业网站建站专业企业网站建设公司
  • mvc net跳转到另一网站建设网官方网站