Skip to content

Instantly share code, notes, and snippets.

@Flybel
Forked from sam0737/clock.html
Last active January 23, 2024 16:19
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 7 You must be signed in to fork a gist
  • Save Flybel/7b5cc4fb00aaeb08317d4cc7418a6e3b to your computer and use it in GitHub Desktop.
Save Flybel/7b5cc4fb00aaeb08317d4cc7418a6e3b to your computer and use it in GitHub Desktop.
OBS Studio: A HTML page for showing current date and time in the video
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>A simple clock</title>
</head>
<body translate="no" >
<div id="output"></div>
<script src='https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment.min.js'></script>
<script>
// https://stackoverflow.com/questions/901115/how-can-i-get-query-string-values-in-javascript
var urlParams;
(function () {
var match,
pl = /\+/g, // Regex for replacing addition symbol with a space
search = /([^&=]+)=?([^&]*)/g,
decode = function (s) { return decodeURIComponent(s.replace(pl, " ")); },
query = window.location.search.substring(1);
urlParams = {};
while (match = search.exec(query))
urlParams[decode(match[1])] = decode(match[2]);
})();
var output = document.getElementById("output");
if (urlParams["style"]) output.setAttribute("style", urlParams["style"]);
if (urlParams["bodyStyle"]) document.body.setAttribute("style", urlParams["bodyStyle"]);
var c;
setInterval(
c = function() {
output.innerText = moment().utc().format(urlParams["format"] || '');
}, 1000);
c();
</script>
</body>
</html>
@SA-Deadspin
Copy link

SA-Deadspin commented Apr 4, 2018

Any way you could do up one to output to EST? I've got people who want to use this but need the broadcasted time to be at EST.

NM, I figured it out. Thanks for this!

@SJP176
Copy link

SJP176 commented Feb 26, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment