日期

1* * 根据险种的可选择年龄区间(年)获取出生年月日展示区间 规则--当前年-年龄/当前月/当前日+1 * */ 2 util.getAgeRangeWithYear = function (age) { 3 let nowDateYear = new Date().getFullYear() - 1; 4 let nowDateMonth = new Date().getMonth() + 1; 5 let nowDateDay = new Date().getDate(); 6 let birthdayYear = nowDateYear - age; let DateStr = birthdayYear + '/' + nowDateMonth + '/' + nowDateDay; // 处理月底最后一天日期加1时安卓和浏览器报错问题 7 let curdate = new Date(new Date(DateStr).getTime() + 1 * 24 * 60 * 60 * 1000); return new Date(curdate); 8 } 9 10 11 12 /* * 根据险种的可选择年龄区间(天)获取出生年月日展示区间 * */ 13 util.getAgeRangeWithDay = function (day) { 14 let currentDate = new Date().getTime(); 15 let minDate = currentDate - day * 24 * 60 * 60 * 1000; // 获取年,月,日 16 let birthdayYear = new Date(minDate).getFullYear(); let birthdayMonth = new Date(minDate).getMonth() + 1; 17 let birthdayDay = new Date(minDate).getDate(); 18 let birthday = birthdayYear + '/' + birthdayMonth + '/' + birthdayDay; 19 return new Date(birthday); 20 },
点赞
收藏

评论区

加载中...

相关推荐

手写Java HashMap源码

HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程22

一篇文章带你了解JavaScript日期

日期对象允许您使用日期(年、月、日、小时、分钟、秒和毫秒)。一、JavaScript的日期格式一个JavaScript日期可以写为一个字符串:ThuFeb02201909:59:51GMT0800(中国标准时间)或者是一个数字:1486000791164写数字的日期,指定的毫秒数自1970年1月1日00:00:00到现在。1\.显示日期使用

Mysql 日期格式化 复杂日期区间查询

前言最近在做项目涉及到Mysql的复杂日期查询,日期查询其实在数据库中查询其实还是用的挺多的,比如查询开始日期到结束日期的区间信息,查询日期小于有效日期的信息,查询当天的日期,明天的日期,做比较等。查询使用场景案例1.时间区间查询查询,2021年06月01号到2021年08月25号的数据javaSELECTFROMdateTestwhe

Java 日期时间

java.util包提供了Date类来封装当前的日期和时间。Date类提供两个构造函数来实例化Date对象。Date() 使用当前日期创建对象Date(longmillisec) 使用时间戳 即 从1970年1月1日开始的毫秒数。Date对象创建以后,可以调用下面的方法。1.booleanafter(Datedate)

mysql时间日期总结

下面对mysql时间和日期处理做下总结1.获取当前日期时间函数nowpythontime.strftime("%Y%y%d%H:%M:%S")selectnow();|2013112309:58:01|2.获取当前日期函数cur

JavaScript 通过身份证号获取出生日期、年龄、性别 、籍贯

JavaScript通过身份证号获取出生日期、年龄、性别、籍贯(很全)效果图:!(https://oscimg.oschina.net/oscnet/805f0196321a1ac3f774290c93d33d6fa71.png)示例代码://由于没有写外部JS,所以代码比较长!!!<!DOCTYPEhtmlPUB