vue.js·获取当前时间

vue.js·获取当前时间:

js·获取当前时间:

funGetDateTime(e){ //获取当前时间
				var now = new Date();
				var Day = now.getDate();//日
				var Month = now.getMonth();//月
				var Year = now.getFullYear();//年
				var Week = now.getDay();//星期
				var unixtime = now.getTime();//时间戳
				
				var h = now.getHours();//时
				var m = now.getMinutes();//分钟
				var s = now.getSeconds();//秒
				var ms = now.getMilliseconds();//毫秒
				
				let obj = {
					year: Year,
					month: Month +1,
					day: Day,
					week: Week,
					unixtime: unixtime,
					h:h,
					m:m,
					s:s,
					ms:ms
				}
				console.log(obj);
				return obj;
			},

js 两个日期天数差

funDateDiff(old,news){//日期计算天差 输入方式2022-07-12
				var sArr = old.split("-");
				var eArr = news.split("-");
				var sRDate = new Date(sArr[0], sArr[1], sArr[2]);
				var eRDate = new Date(eArr[0], eArr[1], eArr[2]);
				var result = (eRDate - sRDate)/(24*60*60*1000);
				return result ;
			}
748 Views
分享你的喜爱
linwute
linwute

我要像梦一样自由,像大地一样宽容;
在艰辛放逐的路上,点亮生命的光芒;
我要像梦一样自由,像天空一样坚强;
在曲折蜿蜒的路上,体验生命的意义;

留下评论

您的电子邮箱地址不会被公开。 必填项已用 * 标注