There are multiple ways to get yesterday's date in JavaScript, one way is to use the Date object and subtract one day from the current date. Another way is to use the Moment.js library which provides more flexibility with formatting and timezone handling.
Here's an example using the Date object:
index.tsx131 chars7 lines
Output:
index.tsx58 chars2 lines
And here's an example using Moment.js:
index.tsx82 chars4 lines
Output:
index.tsx26 chars2 lines
Note that Moment.js provides a formatted timestamp in ISO 8601 format with timezone offset, which can be customized based on your needs.
gistlibby LogSnag