This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Script to get the system time and load it to the logic machine.
#6
.lp example:
Code:
<?
local dt = getvar('dt')

if dt then
  c = dt:split(',')
  if #c == 6 then
    cmd = string.format("date -s '%d-%d-%d %d:%d:%d'", unpack(c))
    io.readproc(cmd)
  end
end
?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Set date/time from client</title>
</head>
<body>
  <? print(os.date()) ?>
  <br>
  <form method="post">
    <input type="hidden" name="dt">
    <input type="button" value="Set date/time">
  </form>
<script>
document.querySelector('input[type=button]').addEventListener('click', function() {
  var d = new Date();
  var dt = [
    d.getFullYear(),
    d.getMonth() + 1,
    d.getDate(),
    d.getHours(),
    d.getMinutes(),
    d.getSeconds()
  ].join(',');

  document.querySelector('input[type=hidden]').value = dt;
  document.querySelector('form').submit();
});
</script>
</body>
</html>
Reply


Messages In This Thread
RE: Script to get the system time and load it to the logic machine. - by admin - 06.09.2019, 11:18

Forum Jump: