Help code _ Climate Clock - Countdown events

Hello p5js community!
This is my first code, sorry for that.
the result should be YRS: Y Day: DDD hh: mm: ss
such as https://climateclock.world
I wrote this code but the days calculation doesn’t work. can you help me ?

</>
var years = year();
var days = day();
var hours = hour();
var minutes = minute();
var seconds = second();

if(seconds != prevSec) {
prevSec = seconds;
years = nf (2027 - years, 1,0);
days = nf (days, 3,0);
hours = nf(24 - hours, 2, 0);
minutes = nf(60 - minutes, 2, 0);
seconds = nf(60 - seconds, 2, 0);

Text(years + "-" + days + "-"+ hours + ":" + minutes + ":" + seconds);

}

</>

Resolved:

	var years = year();
  var hours = hour();
  var minutes = minute();
  var seconds = second();
	
	var now = new Date();
	var start = new Date(now.getFullYear(), 0, 0);
	var diff = now - start;
	var oneDay = 1000 * 60 * 60 * 24;
	var days = 366-Math.floor(diff / oneDay);

  if(seconds != prevSec) {
    prevSec = seconds;
		years = nf (2027 - years, 1,0);
		days = nf (days, 3,0);
    hours = nf(24 - hours, 2, 0);
    minutes = nf(60 - minutes, 2, 0);
    seconds = nf(60 - seconds, 2, 0);
	
    updateText(years + "-" + days + "-"+ hours + ":" + minutes + ":" + seconds);
  }
1 Like