# Access data in template node using mustache

**URL:** <https://discourse.nodered.org/t/access-data-in-template-node-using-mustache/7441>\
**Category:** General\
**Created:** [31 January 2019 17:17 UTC](https://discourse.nodered.org/t/access-data-in-template-node-using-mustache/7441 "2019-01-31T17:17:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![KevinPamu](https://avatars.discourse-cdn.com/v4/letter/k/ba9def/32.png) [@KevinPamu](https://discourse.nodered.org/u/KevinPamu)\
**Post date:** [31 January 2019 17:17 UTC](https://discourse.nodered.org/t/access-data-in-template-node-using-mustache/7441/1 "2019-01-31T17:17:46Z")

</div>

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 = 1000_60_60\*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](https://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](https://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?

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [31 January 2019 17:45 UTC](https://discourse.nodered.org/t/access-data-in-template-node-using-mustache/7441/2 "2019-01-31T17:45:11Z")

</div>

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](https://discourse.nodered.org/t/how-to-share-code-or-flow-json/506?u=ukmoose) it makes it so much easier to read

---

<div class="post-metadata">

**Author:** ![KevinPamu](https://avatars.discourse-cdn.com/v4/letter/k/ba9def/32.png) [@KevinPamu](https://discourse.nodered.org/u/KevinPamu)\
**Post date:** [31 January 2019 22:39 UTC](https://discourse.nodered.org/t/access-data-in-template-node-using-mustache/7441/3 "2019-01-31T22:39:56Z")

</div>

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