<!-- clock hack -->
<!DOCTYPE html>
<html lang="ru">
<head>
<title>Пример</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<script type="text/javascript">
var dt = new Date();
// Display the month, day, and year. getMonth() returns a 0-based number.
var day = dt.getDate()+5;
var month = dt.getMonth()+1;
var year = dt.getFullYear();
document.write(day + '-' + month + '-' + year);
// Output: current month, day, year
</script>
</body>
</html>
var dt = new Date();
var date = dt.getDate();
if( date < 15) dt.setDate(1); // до 15-го числа будет 1-е
else dt.setDate(15); // после 15-го – 15-е
// Display the month, day, and year. getMonth() returns a 0-based number.
var day = dt.getDate();
var month = dt.getMonth()+1;
var year = dt.getFullYear();
document.write(day + '-' + month + '-' + year);
<div> Current Time
<span id="clock"></span>
</div>
window.onload = function(){
function showClock(){
var time = new Date();
var hour = time.getHours();
var minute = time.getMinutes();
var sec = time.getSeconds();
var timeFormatter = digitFormatter(hour)+':'+digitFormatter(minute)+':'+digitFormatter(sec);
var clock = document.getElementById("clock");
clock.textContent = timeFormatter;
}
function digitFormatter(num){
if(num<10){
return '0'+num;
}else{
return num;
}
}
showClock();
setInterval(showClock,1000)
}