I need to get the end of the month in epoch time according to each user's timezone to provide user-friendly experience.
As an example for a user in Sri Lanka, it could be March while in the US it's still February. I need a reliable way to calculate the timestamp without interference from the server locale time. So I could host it anywhere in the world without running into a problem
It should be calculated as follows,
- get current year and month according to the
locale timezone
I tried to use
Intl API
but couldn't figure out
- then get the last day of this month or fisrt day of next month
new Date (locale_year,locale_month+1,0)
- convert to epoch timestamp
.valueOF()
tried to use the timezone option TimeZone
in JS Intl API