Hello!
I have, at least for me, an interesting problem:
Every day I need to save a value from the day before into a csv file.
Therefore I create a file based on month/year and create a line for each day and the respective value.
The problem I have is at months end/months beginning...
How do I get yesterdays date?
Thank you!
This is my current code:
var d = new Date();
var year = d.getFullYear();
var month = d.getMonth()+1;
var day = (d.getDate()-1);
if(month.toString().length == 1) {
var month = '0'+month;
}
msg.filename = "/mnt/data/PVDaten/Tagesdaten"+year+month+".csv";
msg.payload = msg.payload.toString()
msg.payload = day+","+(Number(msg.payload)/10)
return msg;