Menu="OtherSettings"
Title="Date and Time"
Icon="icon-clock"
Tag="clock-o"
---
<?PHP
/* Copyright 2005-2021, Lime Technology
 * Copyright 2012-2021, Bergware International.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License version 2,
 * as published by the Free Software Foundation.
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 */
?>
<?$keys = explode("\n", file_get_contents('webGui/include/timezones.key'));?>

<form markdown="1" name="datetime_settings" method="POST" action="/update.htm" target="progressFrame">
_(Current date and time)_:
: <?=_(my_time(time()),0)?>

_(Time zone)_:
: <select name="timeZone" size="1"><?
  foreach ($keys as $key) {
    [$timezone, $city] = my_explode('|', $key);
    echo mk_option($var['timeZone'], $timezone, $city);
  }
?></select>

:timezone_help:

_(Use NTP)_:
: <select name="USE_NTP" size="1" onchange="checkDateTimeSettings(this.form)">
  <?=mk_option($var['USE_NTP'], "yes", _('Yes'))?>
  <?=mk_option($var['USE_NTP'], "no", _('No'))?>
  </select>

:use_ntp_help:

_(NTP server)_ 1:
: <input type="text" name="NTP_SERVER1" maxlength="40" class="narrow" value="<?=htmlspecialchars($var['NTP_SERVER1'])?>">

:ntp_server1_help:

_(NTP server)_ 2:
: <input type="text" name="NTP_SERVER2" maxlength="40" class="narrow" value="<?=htmlspecialchars($var['NTP_SERVER2'])?>">

:ntp_server2_help:

_(NTP server)_ 3:
: <input type="text" name="NTP_SERVER3" maxlength="40" class="narrow" value="<?=htmlspecialchars($var['NTP_SERVER3'])?>">

:ntp_server3_help:

_(NTP server)_ 4:
: <input type="text" name="NTP_SERVER4" maxlength="40" class="narrow" value="<?=htmlspecialchars($var['NTP_SERVER4'])?>">

:ntp_server4_help:

_(New date and time)_:
: <input type="text" name="newDateTime" maxlength="20" class="narrow" value="<?=my_time(time(), "%F %T")?>">

:current_time_help:

&nbsp;
: <input type="submit" name="setDateTime" value="_(Apply)_" disabled><input type="button" value="_(Done)_" onclick="done()">
</form>

<script>
function checkDateTimeSettings() {
  form = document.datetime_settings;
  if (form.USE_NTP.value=="yes") {
    form.newDateTime.disabled=true;
    form.NTP_SERVER1.disabled=false;
    form.NTP_SERVER2.disabled=false;
    form.NTP_SERVER3.disabled=false;
    form.NTP_SERVER4.disabled=false;
  } else {
    form.newDateTime.disabled=false;
    form.NTP_SERVER1.disabled=true;
    form.NTP_SERVER2.disabled=true;
    form.NTP_SERVER3.disabled=true;
    form.NTP_SERVER4.disabled=true;
  }
}
$(checkDateTimeSettings);
</script>
