UNIX Timestamp in ein lesbares Datum Uhrzeit Format

Ein kleines JavaScript zum umrechnen, oder viel mehr lesbar machen des Unix Timestamp.

HTML:
unixtimestamp.htm HTML (793 Bytes) 21.02.2021 00:27
<!DOCTYPE html >
<html lang="en">
  <head>
    <title>timestamp-to-datetime and datetime-to-timestamp</title>
    <meta charset="utf-8" />
  </head>
  <body>
    <form><label for="timestamp">UNIX TimeStamp:</label><input type="text" id="timestamp" /><button type="button" id="toDT" data-type="timestamp-to-datetime" data-src="timestamp" data-dest="datetime" title="convert to Date/Time">></button><button type="button" id="toTS" data-type="datetime-to-timestamp" data-src="datetime" data-dest="timestamp" title="convert to UNIX Timestamp"><</button><label for="datetime">Date/Time:</label><input type="text" id="datetime" /></form>
    <script src="unixtimestamp.js"></script>
  </body>
</html>
JavaScript:
unixtimestamp.js JavaScript (722 Bytes) 08.09.2021 16:02
// coding: utf-8
/** Created by: Udo Schmal | https://www.gocher.me/ */
(function () {
  'use strict';

  var toDT = document.getElementById('toDT');
  if (toDT) {
    toDT.addEventListener('click', function (event) {
      var ts = document.getElementById('timestamp').value;
      var tsDate = new Date(ts * 1000);
      document.getElementById('datetime').value = tsDate.toGMTString();
    });
  }
  var toTS = document.getElementById('toTS');
  if (toTS) {
    toTS.addEventListener('click', function (event) {
      var dt = document.getElementById('datetime').value;
      var tsDate = new Date(dt);
      document.getElementById('timestamp').value = tsDate.getTime() / 1000;
    });
  }
})();

Kontakt

Udo Schmal
Udo Schmal

Udo Schmal
Softwareentwickler
Ellerndiek 26
24837 Schleswig
Schleswig-Holstein
Germany




+49 4621 9785538
+49 1575 0663676
+49 4621 9785539
SMS
WhatsApp

Google Maps Profile
Instagram Profile
vCard 2.1, vCard 3.0, vCard 4.0

Service Infos

CMS Info

Product Name:
UDOs Webserver
Version:
0.5.1.217
Description:
All in one Webserver
Copyright:
Udo Schmal
Compilation:
Sun, 10. Nov 2024 00:22:34

Development Info

Compiler:
Free Pascal FPC 3.3.1
compiled for:
OS:Linux, CPU:x86_64

System Info

OS:
Ubuntu 22.04.5 LTS (Jammy Jellyfish)

Hardware Info

Model:
Hewlett-Packard HP Pavilion dm4 Notebook PC
CPU Name:
Intel(R) Core(TM) i5-2430M CPU @ 2.40GHz
CPU Type:
x86_64, 1 physical CPU(s), 2 Core(s), 4 logical CPU(s),  MHz