All pastes #283760 Raw Edit

javascript countdown

public text v1 · immutable
#283760 ·published 2006-12-18 16:12 UTC
rendered paste body
function jstimer(timer_span) {
	//defaults
	year="2068"; month="1"; day="1"; hour="00"; min="00"; sec="00"; tz_hours = -8; //PST

	this.timer_span = timer_span;

	strdate = timer_span.innerHTML;
	date_and_time = strdate.split(' ');

	if (typeof(date_and_time[0]) != 'undefined' && date_and_time[0] != '') {
		date_only = date_and_time[0].split('-');
		year  = date_only[0] || year;
		month = date_only[1] || month ;
		day   = new String(date_only[2] || day) ;
		//alert("year: "+year+" month: "+month+" day: "+day);
	} 

	if (typeof(date_and_time[1]) != 'undefined' && date_and_time[1] != '') {
		time_only = date_and_time[1].split(':');
		hour = time_only[0] || hour;
		min  = time_only[1] || min;
		sec  = time_only[2] || sec;
		//alert("hour: "+hour+" min: "+min+" sec: "+sec);
	} 
      
	if (typeof(date_and_time[2]) != 'undefined' && date_and_time[2] != '') {
		tz_hours = date_and_time[2];
	} 
      
	this.to_date = new Date();
	this.to_date.setFullYear(year,month-1,day);
	this.to_date.setHours(hour);
	this.to_date.setMinutes(min);
	this.to_date.setSeconds(sec);
     
	alert(this.to_date);