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.

Datumformat (String) überprüfen ???

Empfohlene Antworten

Veröffentlicht

Hallo!

Ich möchte überprüfen, ob der Benutzer ein Datum im Fomat dd.mm.yyyy eingegeben hat. Hat jemand eine entsprechende Funktion parat (am besten kurz und knapp)? Danke euch vielmals ;-)

Hallo,

falls du zuerst einmal auf das Format ueberpruefen willst, kannst du folgendes benutzen:



$eingabe="..." // Datum aus Formular

if (preg_match("/^(\d{1,2})\.(\d{1,2})\.(\d{2}|\d{4})$",$eingabe,$ergebnis))
{
echo "Eingegebenes Format stimmt.<br>";
echo "Tag: ".$ergebnis[1];
echo "Monat: ".$ergebnis[2];
echo "Jahr: ".$ergebnis[3];
} else {
echo "Das war wohl nix";
}
[/PHP]

Es wird auf folgendes ueberprueft: tag.monat.jahr, wobei tag ein- oder zweistellig sein darf, monat ebenfalls, und jahr zwei- oder vierstellung.

Solltest du auf tag/monat=zweistellung und jahr=vierstellung bestehen wollen, nimm das:

preg_match("/^(\d{2})\.(\d{2})\.(\d{4})$",$eingabe,$ergebnis)

Der Code ist ungetestet, da ich hier grad keine Moeglichkeit habe, sollte aber prinzipiell funktionieren :-)

Michael

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.