Home > Mobile >  Timestamps for future intervals
Timestamps for future intervals

Time:01-31

I have to store my user's availability for example (mon-wed, 10 am to 1 pm), and then use this data to query their calendars to check if they are busy/free

So let's say today it's 29 Jan, Saturday. I want to check availability for the upcoming Tuesday. Now I'll have to generate timestamps for the upcoming Tuesday which would be 1643673600 to 1643846400

How do I generate them? I wanted to write some logic but I have failed. I want to consider the user's timezone too. Is there any API service or package that I can use for this purpose?

CodePudding user response:

check "day.js" npm package, that should help you a lot, it has unix timestamps as well as timezones support

more info https://day.js.org/en/

CodePudding user response:

There is a package called "MomentJs".

Here is a link to the main document page

Here is a link to the document for Unix Timestamp

Use this below code if it solves your problem.

moment().add(3, 'days').unix()

console.log(moment().add(3, 'days').unix());
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.1/moment.min.js"></script>

  •  Tags:  
  • Related