const getRandomISODateNearLastHour = function () {
let dt = new Date();
let timesamp = dt.getTime();
timesamp -= 3600 * 1000;
let dt2 = new Date(timesamp);
dt2.setMinutes(Math.random() * 60, Math.random() * 60, Math.random() * 100);
return dt2.toISOString();
};
This code return 1969-12-31T23:14:21.049Z at Cloudflare Pages and 2022-03-05T08:50:20.097Z at local (with obvious small difference due to random) with Wrangler2 0.16
It seems that Cloudflare Pages Functions return 01/01/1970 to new Date()
but it must returns the current date cf: MDN
NodeJS is set at the same version with environment variable.