Js date returns different date on server vs client

Functions log is showing this:

May 25, 08:05:28 PM: e76d4415 INFO   2022-05-26T01:05:28.840Z
May 25, 08:05:28 PM: e76d4415 INFO   2022-05-26

runs fine locally.
Here’s the code

let today = new Date();

  console.log(today);

  let dd = String(today.getDate()).padStart(2, "0");

  let mm = String(today.getMonth() + 1).padStart(2, "0");

  let yyyy = today.getFullYear();

  today = yyyy + "-" + mm + "-" + dd;

  console.log(today);

Why is code getting a different date and time on the server? I want to get the user’s local date/time

Hey @kableeth

I believe the clock where functions run is set to UTC, whereas the client is set to whichever timezone the user is browsing from.

2 Likes