How can I translate this pseudo code into working js [don\'t worry about where the end date comes from except that it\'s a valid javascript date].
var myEndD
var date=new Date();
//here I am using "-30" to subtract 30 minutes from the current time.
var minute=date.setMinutes(date.getMinutes()-30);
console.log(minute) //it will print the time and date according to the above condition in Unix-timestamp format.
you can convert Unix timestamp into conventional time by using new Date()
.for example
var extract=new Date(minute)
console.log(minute)//this will print the time in the readable format.
Everything is just ticks, no need to memorize methods...
var aMinuteAgo = new Date( Date.now() - 1000 * 60 );
or
var aMinuteLess = new Date( someDate.getTime() - 1000 * 60 );
After working with momentjs, I have to say this is an amazing library you should check out. It is true that ticks work in many cases making your code very tiny and you should try to make your code as small as possible for what you need to do. But for anything complicated, use momentjs.
Try as below:
var dt = new Date();
dt.setMinutes( dt.getMinutes() - 20 );
console.log('#####',dt);