Timestamp for following noon

Hi

I'm struggling to work out how to generate a time stamp for the next noon. Any help would be appreciated, ideally a node if anyone know of one.

thanks

Solved, someone sent me the below which he modified from something he found on the forum

// Get current time in millisecs since Jan 1st 1970
var now = Date.now();

// Calculate the timestamp of midnight at the start of today:
var tstamp = Math.floor(now/86400000)*86400000;

// Add on 36 hours from last midnight to get to noon tomorrow
tstamp += 129600000;

msg.payload = tstamp
return msg;

You can also get the midnight value like this.

var d = new Date();
d.setHours(0, 0, 0, 0);

I was wondering if you meant noon tomorrow, or the next noon: today or tomorrow.

I was looking for next noon so could be in 1 minute or 23 hours 59 minutes, thanks

I think that gives you noon tomorrow in London. If you want noon local time and am not in GMT timezone then you will have to adjust for that.

Colin

Thanks, I have seen a floor in it!! I don't actually mind it it is an hour either side, just looking at solar irridation for the day ahead. On the basis the result is only needed between midnight and 7am I think I would get away with changing tstamp += 129600000 to tstamp += 43200000 which will give me midday the same day

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.