<!DOCTYPE html>
<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>Untitled 1</title>
</head>
<body>
<div id="disp"></div>
<script>
function to2(t){ return (t<10 ? "0"+t : t ); }
function get_today(mplus=0) // 0 current month else + month // YYYY-MM-DD HH:MM:SS
{
var today = new Date();
if (mplus != 0)
today = new Date(today.getFullYear(),today.getMonth()+mplus,today.getDate(),today.getHours(),today.getHours(),today.getSeconds());
// The plus one in the month is to provide 1..12 in the month counter
return today.getFullYear()+'-'+to2(today.getMonth()+1)+'-'+to2(today.getDate())+" "+to2(today.getHours()) + ":" +to2(today.getHours()) + ":" + to2(today.getSeconds());
}
document.getElementById("disp").innerHTML = get_today()+"<br>"+get_today(7);
</script>
</body>
</html>