by @kodeazy
How to convert a Javascript timestamp of Date into yyyy/MM/dd HH:mm:ss format ?
To get the current timestamp use getTime()
function of new Date()
var tstamp=(new Date()).getTime();
timestamp I got was
1593442225619
To get the date format of any timestamp add the timestamp inside the date function in number format
var date = new Date(tstamp);
after converting the timestamp into date
Mon Jun 29 2020 20:21:07 GMT+0530 (India Standard Time)
To get the date in yyyy/MM/dd HH:mm:ss format
var date_format_str = date.getFullYear().toString()+"-"+((date.getMonth()+1).toString().length==2?(date.getMonth()+1).toString():"0"+(date.getMonth()+1).toString())+"-"+(date.getDate().toString().length==2?date.getDate().toString():"0"+date.getDate().toString())+" "+(date.getHours().toString().length==2?date.getHours().toString():"0"+date.getHours().toString())+":"+((parseInt(date.getMinutes()/5)*5).toString().length==2?(parseInt(date.getMinutes()/5)*5).toString():"0"+(parseInt(date.getMinutes()/5)*5).toString())+":00";