Einzelnen Beitrag anzeigen
  #1  
Alt 14.05.2016, 19:39:10
ostseepott ostseepott ist offline
Anfänger
 
Registriert seit: May 2016
Alter: 54
Beiträge: 1
Javascript UNIX-Timestamp Picker

Moin Moin habe da ein Problem.

Suche heute schon den Ganzen Tag nach ein html <input> Javascript/Jquery/Bootstrap UNIX-Timestamp Picker.

Habe eins gefunden unter KLICK

Doch wenn ich das script downloade und die anweisung beachte geht da garnix. Weis net Wieso. Ok dann suchte ich nach ein Timestamp Converter. Habe da auch was gefunden in Javascript. Nur Leider muss man den button zum Kreieren selbst Klicken um an den timestamp zu kommen. Will dies aber nicht muss ein Datetime Picker sein.

Habe eine Mysql tabelle mit colum ´datum´ in INT 14 zeichen also für timestamp zeichen.
die spalte ist kein Timestamp nur als (INT). Weis wer eine Lösung?

hier mal der Converter:


Code:
<SCRIPT LANGUAGE="JavaScript">

<!-- Original:  Ryan Sokol  http://www.logicode.net -->

<!-- Begin
<!--
  function Calculate()
  {
    if(document.form1.switcher.value == "=>")
      timeToHuman();
    else if(document.form1.switcher.value == "<=")
      humanToTime();
  }
  function timeToHuman()
  {
    var theDate = new Date(document.form1.timeStamp.value * 1000);
    dateString = theDate.toGMTString();
    arrDateStr = dateString.split(" ");
    document.form1.inMon.value = getMonthNum(arrDateStr[2]);
    document.form1.inDay.value = arrDateStr[1];
    document.form1.inYear.value = arrDateStr[3];
    document.form1.inHr.value = arrDateStr[4].substr(0,2);
    document.form1.inMin.value = arrDateStr[4].substr(3,2);
    document.form1.inSec.value = arrDateStr[4].substr(6,2);
  }
  function humanToTime()
  {
    var humDate = new Date(Date.UTC(document.form1.inYear.value,
          (stripLeadingZeroes(document.form1.inMon.value)-1),
          stripLeadingZeroes(document.form1.inDay.value),
          stripLeadingZeroes(document.form1.inHr.value),
          stripLeadingZeroes(document.form1.inMin.value),
          stripLeadingZeroes(document.form1.inSec.value)));
    document.form1.timeStamp.value = (humDate.getTime()/1000.0);
  }
  function pointRight()
  {
    document.form1.switcher.value="=>";
  }
  function pointLeft()
  {
    document.form1.switcher.value="<=";
  }
  function stripLeadingZeroes(input)
  {
    if((input.length > 1) && (input.substr(0,1) == "0"))
      return input.substr(1);
    else
      return input;
  }
  function getMonthNum(abbMonth)
  {
    var arrMon = new Array("Jan","Feb","Mar","Apr","May","Jun",
          "Jul","Aug","Sep","Oct","Nov","Dec");
    for(i=0; i<arrMon.length; i++)
    {
      if(abbMonth == arrMon[i])
        return i+1;
    }
  }
//  End -->
</script>


<center><form name=form1>
<table border=0>
<tr>
  <th>Timestamp Sek:</th>
  <td valign=bottom rowspan=2>
    <input type=button name=switcher value="=>" onClick="Calculate();"></td>
  <th>Mon:</th>
  <th> </th>
  <th>Tag:</th>
  <th> </th>
  <th>Jahr:</th>
  <th> </th>
  <th>Stu:</th>
  <th> </th>
  <th>Min:</th>
  <th> </th>
  <th>Sek:</th>
  <th> </th>
</tr>
<tr>
  <td align=center><input type=text size=14 maxlength=11 name=timeStamp onKeyUp="pointRight();"></td>
  <td><input type=text size=4 maxlength=2 name=inMon onKeyUp="pointLeft();"></td>
  <th>/</th>
  <td><input type=text size=4 maxlength=2 name=inDay onKeyUp="pointLeft();"></td>
  <th>/</th>
  <td><input type=text size=4 maxlength=4 name=inYear onKeyUp="pointLeft();"></td>
  <th>at</th>
  <td><input type=text size=4 maxlength=2 name=inHr onKeyUp="pointLeft();"></td>
  <th>:</th>
  <td><input type=text size=4 maxlength=2 name=inMin onKeyUp="pointLeft();"></td>
  <th>:</th>
  <td><input type=text size=4 maxlength=2 name=inSec onKeyUp="pointLeft();"></td>
  <th>GMT</th>
</tr>
</table>
</form></center>
Mit Zitat antworten