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 (769 bytes) 20.12.2020 13:33
<!DOCTYPE html >
<html lang="en">
  <head>
    <meta charset="utf-8" />
  </head>
  <body>
    <form action=""><label for="timestamp">UNIX TimeStamp:</label><input type="text" id="timestamp" style="width: 200px;" value="" /><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" style="width: 200px;" value="" /></form>
    <script src="unixtimestamp.js"></script>
  </body>
</html>
JavaScript:
unixtimestamp.js JavaScript (718 bytes) 20.12.2020 13:35
// 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;
    });
  }
})();

Author: , published: , last modified:

Kontakt

Udo Schmal

Udo Schmal
Softwareentwickler
Olvengraben 41
47608 Geldern
Nordrhein-Westfalen
Germany





+49 2831 9776557
+49 1575 0663676
+49 2831 1328709
SMS
WhatsApp

Instagram Profile
vCard 3.0

Service Infos

CMS Info Product Name:
UDOs Webserver
Version:
0.4.2.101
Description:
All in one Webserver
Copyright:
Udo Schmal
Compilation:
Mon, 18. Jan 2021 23:28:31
Development Info Compiler:
Free Pascal FPC 3.3.1
compiled for:
OS:Linux, CPU:x86_64
System Info OS:
Ubuntu 20.04.1 LTS (Focal Fossa)
Hardware Info Model:
Hewlett-Packard HP Pavilion dv7 Notebook PC
CPU Name:
Intel(R) Core(TM) i5-2450M CPU @ 2.50GHz
CPU Type:
x86_64, 1 physical CPU(s), 2 Core(s), 4 logical CPU(s), 2274.761 MHz