[2025-04-13] Send full time string in Javascript
This commit is contained in:
parent
3c561b7975
commit
b04e4b078a
@ -1,18 +1,18 @@
|
|||||||
<html>
|
<html>
|
||||||
<div style="visibility: hidden">
|
<div style="visibility: hidden">
|
||||||
<form id="form" method="POST" action="/">
|
<form id="form" method="POST" action="/">
|
||||||
<input name="timestamp" id="timestamp" type="number"></input>
|
<input name="date" id="date" type="text"></input>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</html>
|
</html>
|
||||||
<script>
|
<script>
|
||||||
window.onload = function(e){
|
window.onload = function(e){
|
||||||
var d = new Date();
|
var d = new Date();
|
||||||
var timestamp = Math.round(d.getTime() / 1000);
|
var date = d.toUTCString();
|
||||||
input = document.getElementById("timestamp")
|
dateform = document.getElementById("date")
|
||||||
input.value = timestamp;
|
dateform.value = date;
|
||||||
form = document.getElementById("form")
|
form = document.getElementById("form")
|
||||||
form.submit();
|
form.submit();
|
||||||
console.log(timestamp);
|
console.log(iso);
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -175,7 +175,8 @@ def getHomoSapiens(yearPercent):
|
|||||||
return f"Homo Sapiens have been around for ~{-math.floor(yearsUntilHumans)} years"
|
return f"Homo Sapiens have been around for ~{-math.floor(yearsUntilHumans)} years"
|
||||||
|
|
||||||
def getTemplate(timestamp):
|
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")
|
nowTime = now.strftime("%-I:%M%p")
|
||||||
nowDate = now.strftime("%A") + " " + now.strftime("%-d") + " " + now.strftime("%B")
|
nowDate = now.strftime("%A") + " " + now.strftime("%-d") + " " + now.strftime("%B")
|
||||||
|
|
||||||
@ -215,7 +216,7 @@ def index(timestamp):
|
|||||||
@app.route("/", methods=["GET","POST"])
|
@app.route("/", methods=["GET","POST"])
|
||||||
def init():
|
def init():
|
||||||
if request.method == "POST":
|
if request.method == "POST":
|
||||||
timestamp = int(request.values.get('timestamp'))
|
timestamp = request.values.get('date')
|
||||||
return index(timestamp)
|
return index(timestamp)
|
||||||
else:
|
else:
|
||||||
return render_template("init.html")
|
return render_template("init.html")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user