I'm trying to format date in JS as below to formating as Y-m-d But I want to get ymdms.
datestr = current.toISOString().split('T')[0];
resulting_dates.push(datestr);//dates.push(d.toISOString().split('T')[0]);
I'm trying to format date in JS as below to formating as Y-m-d But I want to get ymdms.
datestr = current.toISOString().split('T')[0];
resulting_dates.push(datestr);//dates.push(d.toISOString().split('T')[0]);
Here is a working example you can modify the date to get your preferred format :
<button onclick="myFunction();">Try it</button>
<p id="demo"></p>
<script>
function myFunction() {
var currentdate = new Date();
var currentdate = new Date();
var datetime = currentdate.getDate() + "/"+ (currentdate.getMonth()+1) + "/" + currentdate.getFullYear() + " "+ currentdate.getHours() + ":" + currentdate.getMinutes() + ":" + currentdate.getSeconds();
document.getElementById("demo").innerHTML = datetime;
}
</script>