Показать сообщение отдельно
  #4 (permalink)  
Старый 23.05.2019, 09:27
Аватар для рони
Профессор
Отправить личное сообщение для рони Посмотреть профиль Найти все сообщения от рони
 
Регистрация: 27.05.2010
Сообщений: 33,064

дата исполнения заказа в зависимости от времени

<!DOCTYPE html>

<html>
<head>
  <title>Untitled</title>
  <meta charset="utf-8">
  <script>
Date.prototype.setTimezoneOffset = function(minutes) {
    var _minutes;
    if (this.timezoneOffset == _minutes) {
        _minutes = this.getTimezoneOffset();
    } else {
        _minutes = this.timezoneOffset;
    }
    if (arguments.length) {
        this.timezoneOffset = minutes;
    } else {
        this.timezoneOffset = minutes = this.getTimezoneOffset();
    }
    return this.setTime(this.getTime() + (_minutes - minutes) * 6e4);
};

function getDate(hoursEnd, timeZone)
{
    var time = new Date;
    time.setTimezoneOffset(-180);
    var hours = time.getHours();
    if(hours >= hoursEnd) time.setDate(time.getDate() + 1);
    return time.toLocaleString('ru', {
        year: 'numeric',
        month: 'long',
        day: 'numeric'
      });
}
addEventListener('load', () => document.querySelector('.executionDate').textContent = getDate(16, -180))
</script>
</head>

<body>
<div class="executionDate"></div>

</body>
</html>

... Igor_Gerasimov, Учебник
Ответить с цитированием