Countdown to the weekend

Point me to a script you like and I’ll show you how to embed my code :slight_smile:

Welcome to SitePoint!

Yes, you posted in the correct place :tup:

I don’t know any script that does exactly what you want, but I can offer you this simple script:

var now=new Date();
var Y = now.getFullYear();
var m = now.getMonth();
var d = now.getDate();

var date = new Date();
while (date.getDay() != 6) {
  date = new Date(Y,m,++d);

var target = new Date(Y,m,d,0,0,1);

The variable “target” that is created is a date object for the next saturday 0:00:01.
If you feed this variable to a normal javascript countdown script (so instead of setting the variable of the target date, give it the target variable) it should work.

If you have any questions don’t hesitate to ask :slight_smile:

function moronCode(){
	var A= [], now= new Date(),
	d, x, D, day= now.getDay();
	if(!day%6) return '';
	D= new Date(now);
	D.setHours(0, 0, 0, 0);
	x= D-now;
	d= Math.floor(x/8.64e7);
	if(d> 1){
		A.push(d+' days');
		x%= 8.64e7;
	x= Math.floor(x/1000);
	if(x> 3600){
		d= Math.floor(x/3600);
		A.push(d+' hour'+((d> 1)? 's': ''));
		x%= 3600;
	if(x> 60){
		d= Math.floor(x/60);
		A.push(d+' minute'+((d> 1)? 's': ''));
		x%= 60;
	if(x> 0) A.push(x+' second'+((x> 1)? 's': ''));
	return A.join(', ');