Skip to content

Instantly share code, notes, and snippets.

@samyarvahid
Last active May 25, 2017 18:55
Show Gist options
  • Save samyarvahid/14e597d5839e1d8604cea57bb238a02f to your computer and use it in GitHub Desktop.
Save samyarvahid/14e597d5839e1d8604cea57bb238a02f to your computer and use it in GitHub Desktop.
new datetime format for ISO
#by @mishalarionov
#http://mishalarionov.com/hidden/datetime.html
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
</head>
<body
style="display:flex;justify-content:center;align-items:center;font-family:'Comic Sans MS'"
onload="window.setInterval(function(){
var today = new Date();
$('#yearDigit1').text(today.getYear().toString().charAt(0));
$('#yearDigit2').text(today.getYear().toString().charAt(1));
$('#yearDigit3').text(today.getYear().toString().charAt(2));
$('#yearDigit4').text(today.getYear().toString().charAt(3));
$('#date').text(today.getDate());
$('#month').text(today.getMonth() + 1);
if (today.getMonth() + 1 < 10) {
$('#month').text('0' + (today.getMonth() + 1));
}
$('#time').text(parseInt(today.getHours().toString() + today.getMinutes().toString()) * parseInt(today.getHours().toString() + today.getMinutes().toString()));
$('#secondsCubed').text(today.getSeconds() * today.getSeconds() * today.getSeconds());
$('#millisecondsToTheFour').text(today.getMilliseconds() * today.getMilliseconds() * today.getMilliseconds() * today.getMilliseconds());
}, 1);
">
<h1>
<span id="yearDigit1"></span><span id="date"></span><span id="yearDigit2"></span>-<span id="yearDigit3"></span><span id="month"></span><span id="yearDigit4"></span>-<span id="time"></span>-<span id="secondsCubed"></span>-<span id="millisecondsToTheFour"></span>
</h1>
<script type="text/javascript">
console.log("Hello, world!");
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment