[2025-04-13] Send full time string in Javascript

This commit is contained in:
Andrew Conlin 2025-04-14 04:48:14 +09:00
parent 3c561b7975
commit b04e4b078a
2 changed files with 8 additions and 7 deletions

View File

@ -1,18 +1,18 @@
<html>
<div style="visibility: hidden">
<form id="form" method="POST" action="/">
<input name="timestamp" id="timestamp" type="number"></input>
<input name="date" id="date" type="text"></input>
</form>
</div>
</html>
<script>
window.onload = function(e){
var d = new Date();
var timestamp = Math.round(d.getTime() / 1000);
input = document.getElementById("timestamp")
input.value = timestamp;
var date = d.toUTCString();
dateform = document.getElementById("date")
dateform.value = date;
form = document.getElementById("form")
form.submit();
console.log(timestamp);
console.log(iso);
}
</script>

View File

@ -175,7 +175,8 @@ def getHomoSapiens(yearPercent):
return f"Homo Sapiens have been around for ~{-math.floor(yearsUntilHumans)} years"
def getTemplate(timestamp):
now = datetime.datetime.fromtimestamp(timestamp)
# Tue, 22 Nov 2011 06:00:00 GMT
now = datetime.datetime.strptime(timestamp,"%a, %d %b %Y %H:%M:%S %Z")
nowTime = now.strftime("%-I:%M%p")
nowDate = now.strftime("%A") + " " + now.strftime("%-d") + " " + now.strftime("%B")
@ -215,7 +216,7 @@ def index(timestamp):
@app.route("/", methods=["GET","POST"])
def init():
if request.method == "POST":
timestamp = int(request.values.get('timestamp'))
timestamp = request.values.get('date')
return index(timestamp)
else:
return render_template("init.html")