skip to Main Content

I have this timestamp 1688452200

const startdate = new Date('1688452200')
const newstartDate = new Date(startdate.setMonth(startdate.getMonth() + 1));
console.log('newDate:', newstartDate);
const newStartDateTime = newstartDate.getTime();

want to add 1 month to this timestamp but this is not working

2

Answers


  1. Just convert your UNIX timestamp to the JS timestamp (multiply by milliseconds).

    const startdate = new Date('1688452200' * 1000)
    startdate.setMonth(startdate.getMonth() + 1);
    console.log('newDate:', startdate);
    Login or Signup to reply.
  2. const startdate = new Date(1688452200*1000);
    const newstartDate = new Date(startdate.setMonth(startdate.getMonth() + 1));
    console.log('newDate:', newstartDate);
    const newStartDateTime = newstartDate.getTime();
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search