Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Datum aus Eingabefeld in Javascript Format umwandeln

Empfohlene Antworten

Hallo,

ich möchte die Differenz zwischen einem eingegebenen Datum und dem aktuellen Datum berechnen. Der eigentliche Teil zur Berechnung funktioniert auch. Mein Problem ist die Übergabe des Datums aus dem Eingabefeld. Dieses hat das Format tt.mm.jjjj. Für die Berechnung brauche ich das aber im Format jjjj,mm,tt. Außerdem muss man ja beim Monat eins abziehen, da JavaScript die Monate von 0 an zählt.

Wie kann ich das am besten lösen?

Du musst doch nur das Datum aus dem Eingabefeld aufspitten und die Ergebnisse übergeben.

Beispiel:

<input type='text' name='sDateInput' />

var arr = sDateInput.split("\.");

alert(arr[0]) // Tag

alert(arr[1]) // Monat

alert(arr[2]) // Jahr

dMyDate = new Date(arr[2], arr[1], arr[0], 0, 0, 0);

Wie es weitergeht, weisst Du ja.

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.