Как убрать часы из кода

есть такой код

<html>
 <head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <title>Заголовки</title>
 </head>
 <body> 
   <h2>Дата начала
<pre></pre>
<div id="current_date_time_block"></div>
<p style="border:3px #9c573a  solid;"> </p> 
<script type="text/javascript">
    
    function zero_first_format(value)
    {
        if (value < 10)
        {
            value='0'+value;
        }
        return value;
    }

    function date_time()
    {
        var current_datetime = new Date();
        var day = zero_first_format(current_datetime.getDate());
        var month = zero_first_format(current_datetime.getMonth()+1);
        var year = current_datetime.getFullYear();
        var hours = zero_first_format(current_datetime.getHours());
        var minutes = zero_first_format(current_datetime.getMinutes());
        var seconds = zero_first_format(current_datetime.getSeconds());

        return day+"."+month+"."+year+" "+hours+":"+minutes+":"+seconds;
    }
  document.getElementById('current_date_time_block').innerHTML = date_time();
</script>
</p>
</h2>
 </body>
</html>

как сделать чтобы вывод был только даты, помогите пож-та


Ответы (1 шт):

Автор решения: user711034

Вот пример, как вывести только дату:

<html>
 <head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <title>Заголовки</title>
 </head>
 <body> 
   <h2>Дата начала
<pre></pre>
<div id="current_date_time_block"></div>
<p style="border:3px #9c573a  solid;"> </p> 
<script type="text/javascript">
    
    function zero_first_format(value)
    {
        if (value < 10)
        {
            value='0'+value;
        }
        return value;
    }

    function date_time()
    {
        var current_datetime = new Date();
        var day = zero_first_format(current_datetime.getDate());
        var month = zero_first_format(current_datetime.getMonth()+1);
        var year = current_datetime.getFullYear();
        
        //var hours = zero_first_format(current_datetime.getHours());
        //var minutes = zero_first_format(current_datetime.getMinutes());
        //var seconds = zero_first_format(current_datetime.getSeconds());

        return day+"."+month+"."+year; //+" "+hours+":"+minutes+":"+seconds;
    }
  document.getElementById('current_date_time_block').innerHTML = date_time();
</script>
</p>
</h2>
 </body>
</html>

→ Ссылка