Access data in template node using mustache

#1

Greetings,

I have the following code in the function node.

var now = Date.now();
var year = new Date().getUTCFullYear();
var year_start = Date.UTC(year, 0, 1);
var day_length_in_ms = 10006060*24;
var day_number = Math.floor((now - year_start)/day_length_in_ms);
day_number = day_number + 1;
var d = new Date();
var hr = { payload: d.getHours().toString().padStart(2,"0")};
var mn = { payload: d.getMinutes().toString().padStart(2,"0")};
var sec ={ payload: d.getSeconds().toString().padStart(2,"0")};
//msg.payload = msg.payload.toString().padStart(3,"0");
var padday = { payload: day_number.toString().padStart(3,"0") }
var yearr = {payload : year }
//var all = {yearr,padday,hr,mn,sec};
//msg.payload = all;
return [[yearr,padday,hr,mn,sec]];

I want to access the yearr,padday,hr,mn,sec values in the same template node in a particular manner.
how should I access the values from the template node using mustache?

should I change how I am returning the values?

#2

You need to return an object. so make them all part of that object
eg

msg.hour msg.year etc
Also when sharing code Please read the following post How to share code or flow json it makes it so much easier to read

#3

Thank you, I will keep the how to share code part in mind for next time.