slaurent

SLOBS Clock (Browser Source)

Sep 15th, 2020 (edited)
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 1.40 KB | None | 0 0
  1. <!-- FOR USE AS A BROWSER SOURCE IN (STREAMLABS) OBS -->
  2. <!-- @author: slaurent -->
  3.  
  4. <!DOCTYPE html>
  5. <html lang="en-US">
  6.  
  7. <head>
  8.     <title>Clock</title>
  9.     <meta charset="utf-8">
  10.     <style>
  11.         /* css from AlexxaEmber */
  12.         #clock {
  13.             font: bold 30px monospace;
  14.             color: white;
  15.             display: inline-block;
  16.             border-radius: 5px;
  17.             padding: 2px 5px;
  18.             background-color: rgba(0, 0, 0, 0.5)
  19.         }
  20.     </style>
  21. </head>
  22.  
  23. <body>
  24.     <div id="clock"></div>
  25. </body>
  26. <script type="text/javascript">
  27.     // Intl.DateTimeFormat options are documented at
  28.     // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/DateTimeFormat
  29.     // 15 Sep 2020
  30.     const dateFormat = new Intl.DateTimeFormat("en-GB", {
  31.         day: "2-digit",
  32.         month: "short",
  33.         year: "numeric"
  34.     });
  35.     // 22:13:12 EDT
  36.     const timeFormat = new Intl.DateTimeFormat("en-US", {
  37.         hour: "2-digit",
  38.         minute: "2-digit",
  39.         second: "2-digit",
  40.         timeZoneName: "short",
  41.         hour12: false
  42.     });
  43.     const clockElement = document.getElementById("clock");
  44.     setInterval(() => {
  45.         const now = new Date();
  46.         // 15 Sep 2020 22:13:12 EDT
  47.         clockElement.innerText = `${dateFormat.format(now)} ${timeFormat.format(now)}`;
  48.     }, 500);
  49. </script>
  50.  
  51. </html>
Advertisement
Add Comment
Please, Sign In to add comment