Last month day to write total energy month on DB

Hi,

I'm doing a node red program to report stats in dashboard on photovoltaic installation.
I'm using a RPI and I'm working with SQLite DB.

Every last day of month, I want to write in a SQLite table the enery consumption of that month.

Actually, in a function with this code, I'm getting this result:

14/7/2019, 15:39:22node: ab2700e4.732c7msg.payload : Date
"Wed Jul 31 2019 00:00:00 GMT+0200 (GMT+02:00)"

Think it can work with a comparison on the actual date and time with this last day of month Date to write to DB.
The only thing I would like to change in that result, is this, I wolud prefer this result:
"Wed Jul 31 2019 23:59:59 GMT+0200 (GMT+02:00)"

This is the code I used in function:
var today = new Date();
var lastDayOfMonth = new Date(today.getFullYear(), today.getMonth()+1, 0);
var outp={ payload: (lastDayOfMonth)};
return [outp];

Have you tried specifying hours mins and seconds in your new Date line?
eg

var lastDayOfMonth = new Date(today.getFullYear(), today.getMonth()+1, 0,23,59,59);

Yes, that's working perfect.
Thanks @ukmoose