using moment how do we change or set date and keep unix time format

Can we use moment to change or set the date and maintain the unix time format.

current time format is 1629442800 which in human eyes August 20, 2021 3:00:00 AM.
I would like to change just the date but keep the time the same

current time format is 1629442800 which in human eyes August 20, 2021 3:00:00 AM
desired time 1630047600 which in human eyes  August 27, 2021 3:00:00 AM
//using javascript  not sure how to use this
const currentTime = 1629442800

moment(currentTime).set('year', 2013);
moment(currentTime).set('month', 3);  // April
moment(currentTime).set('date', 1);

console.log(currentTime)

Answer

You create multiple distinct date objects with each call of moment(currentTime), and currentTime will only be used to initialize that data. currentTime won’t be affected by any of the .set calls.

So this part of the code is completely useless:

moment(currentTime).set('year', 2013);
moment(currentTime).set('month', 3);  // April
moment(currentTime).set('date', 1);

You just create the moment date objects, calling .set on them and then you discard the result.

It has to be:

const currentTime = 1629442800

// create a moment time object
const timeObject = moment.unix(currentTime)

// do changes on that object
timeObject.set('year', 2013);
timeObject.set('month', 3);  // April
timeObject.set('date', 1);

// get the unix timestamp form that moment object
console.log(timeObject.unix())
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.1/moment.min.js"></script>