06.09.2019, 11:18
.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>