我怎样才能计算剩余日 [英] How Can I Calculate Remain Day

查看:63
本文介绍了我怎样才能计算剩余日的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨亲爱的程序员

在这个jquery代码我用来计算3个月仍然启动网页,我不知道jquery语言,我怎么能设置变量来计算3个月或90天



hi dear programmers
in this jquery code i use to be calculate the 3 month remain to start the web page, i don't know jquery language as well, how can i set variable to calculate the 3 month or 90 days

(function($) {
	$.fn.ccountdown = function(_yr, _m, _d, _t) {
		var $this = this;
		var _montharray = new Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec")
		var _today = new Date();
		// calling function first time so that it wll setup remaining time
		var _changeTime = function() {
			var _today = new Date();
			var _todayy = _today.getYear();
			if (_todayy < 1000)

				_todayy += 1900;

			var _todaym = _today.getMonth();

			var _todayd = _today.getDate();

			var _todayh = _today.getHours();

			var _todaymin = _today.getMinutes();

			var _todaysec = _today.getSeconds();

			_todaysec = "0" + _todaysec;

			_todaysec = _todaysec.substr(_todaysec.length - 2);

			var _todaystring = _montharray[_todaym] + " " + _todayd + ", " + _todayy + " " + _todayh + ":" + _todaymin + ":" + _todaysec;

			var _futurestring = _montharray[_m - 1] + " " + _d + ", " + _yr + " " + _t;

			/* calculation of remaining days, hrs, min, and secs */

			_dd = Date.parse(_futurestring) - Date.parse(_todaystring);

			_dday = Math.floor(_dd / (60 * 60 * 1000 * 24) * 1);

			_dhour = Math.floor((_dd % (60 * 60 * 1000 * 24)) / (60 * 60 * 1000) * 1);

			_dmin = Math.floor(((_dd % (60 * 60 * 1000 * 24)) % (60 * 60 * 1000)) / (60 * 1000) * 1);

			_dsec = Math.floor((((_dd % (60 * 60 * 60 * 1000 * 24)) % (60 * 60 * 1000)) % (60 * 1000)) / 1000 * 1);

			var el = $($this);

			var $ss = el.find(".second"), $mm = el.find(".minute"), $hh = el.find(".hour"), $dd = el.find(".days");

			$ss.val(_dsec).trigger("change");

			$mm.val(_dmin).trigger("change");

			$hh.val(_dhour).trigger("change");

			$dd.val(_dday).trigger("change");

};

		_changeTime();

		setInterval(_changeTime, 1000);

	};

 

})(jQuery);

推荐答案

){


.fn.ccountdown = function(_yr, _m,_d,_t){
var
.fn.ccountdown = function(_yr, _m, _d, _t) { var


this = this;
var _montharray = new Array(Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct, 十一月,十二月)
var _today = new Date();
//第一次调用函数,以便设置剩余时间
var _changeTime = function(){
var _today = new Date();
var _todayy = _today.getYear();
if(_todayy < 1000)

_ todayy + = 1900;

var _ todaym = _today.getMonth();

var _ todayd = _today.getDate();

var _ todayh = _today.getHours();

var _ todaymin = _today.getMinutes();

var _ todaysec = _today.getSeconds();

_ todaysec = 0 + _ todaysec;

_ todaysec = _ todaysec.substr(_todaysec.length - 2);

var _ todaystring = _montharray [_todaym] + + _ todayd + < span class =code-attribute> + _ todayy + + _ todayh + + < span class =code-attribute> _ todaymin + + _ todaysec;

var _ futurestring = _ montharray [_m - 1] + + _ d + + _ yr + + _ t;

< span class =code-attribute>
/ * 计算 剩余 < span class =code-attribute> days, 小时, min, secs * /

_ dd = Date.parse(_futurestring) - < span class =code-attribute> Date.parse(_todaystring);

_ dday = Math.floor(_dd / (60 * < span class =code-attribute> 60 * 1000 * 24) * 1);

_ dhour = Math.floor((_ dd ( 60 * 60 * 1000 * 24)) / (60 * 60 * 1000) * 1);

\t\t\t_dmin = Math.floor(((_dd % (60 * 60 * 1000 * 24)) % (60 * 60 * 1000)) / (60 * 1000) * 1);

\t\t\t_dsec = Math.floor((((_dd % (60 * 60 * 60 * 1000 * 24)) % (60 * 60 * 1000)) % (60 * 1000)) / 1000 * 1);

\t\t\tv ar el =
this = this; var _montharray = new Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec") var _today = new Date(); // calling function first time so that it wll setup remaining time var _changeTime = function() { var _today = new Date(); var _todayy = _today.getYear(); if (_todayy < 1000) _todayy += 1900; var _todaym = _today.getMonth(); var _todayd = _today.getDate(); var _todayh = _today.getHours(); var _todaymin = _today.getMinutes(); var _todaysec = _today.getSeconds(); _todaysec = "0" + _todaysec; _todaysec = _todaysec.substr(_todaysec.length - 2); var _todaystring = _montharray[_todaym] + " " + _todayd + ", " + _todayy + " " + _todayh + ":" + _todaymin + ":" + _todaysec; var _futurestring = _montharray[_m - 1] + " " + _d + ", " + _yr + " " + _t; /* calculation of remaining days, hrs, min, and secs */ _dd = Date.parse(_futurestring) - Date.parse(_todaystring); _dday = Math.floor(_dd / (60 * 60 * 1000 * 24) * 1); _dhour = Math.floor((_dd % (60 * 60 * 1000 * 24)) / (60 * 60 * 1000) * 1); _dmin = Math.floor(((_dd % (60 * 60 * 1000 * 24)) % (60 * 60 * 1000)) / (60 * 1000) * 1); _dsec = Math.floor((((_dd % (60 * 60 * 60 * 1000 * 24)) % (60 * 60 * 1000)) % (60 * 1000)) / 1000 * 1); var el =


这篇关于我怎样才能计算剩余日的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆