js过期时间

JS 几天后过期

function CheckInfoDate(infodate) {
	// infodate 格式 yyyy-mm-dd
	let today = new Date().getTime();
	let theday = Date.parse(infodate.replace(/(\d+)-(\d+)-(\d+)/, '$2/$3/$1'));
	if (today >= theday)
		console.log("已过期")
	else
		console.log('还剩' + Math.floor((theday - today) / (24 * 3600 * 1000)) + '天');
}
posted @ 2021-07-26 14:53  小泽沐优声  阅读(91)  评论(0编辑  收藏  举报