Menu="OtherSettings"
Title="Date and Time"
Icon="date-time.png"
Tag="clock-o"
---
<?PHP
/* Copyright 2005-2017, Lime Technology
 * Copyright 2012-2017, 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())?>

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

> Select your applicable time zone from the drop-down list.

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

> Select 'Yes' to use Network Time Protocol to keep your server time accurate.
> We **highly** recommend the use of a network time server, especially if you plan on using Active Directory.

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

> This is the primary NTP server to use.  Enter a FQDN or an IP address.

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

> This is the alternate NTP server to use if NTP Server 1 is down.

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

> This is the alternate NTP Server to use if NTP Servers 1 and 2 are both down.

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

> Enter the current time-of-day.  Use format YYYY-MM-DD HH:MM:SS. Greyed out when using NTP.

&nbsp;
: <input type="submit" name="setDateTime" value="Apply"><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;
  } else {
    form.newDateTime.disabled=false;
    form.NTP_SERVER1.disabled=true;
    form.NTP_SERVER2.disabled=true;
    form.NTP_SERVER3.disabled=true;
  }
}
$(checkDateTimeSettings);
</script>
