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.

Empfohlene Antworten

Veröffentlicht

Hallo Forum,

ich habe eine Variable in der sich ein Datum befindet. Das Datum selbst ist wie folgt formatiert:

2006.01.01

Ich möchte das dieses Datum um x-Tage addiert wird. Egal was ich bisher versucht habe, es klappt nicht.

Wenn einer weiß wie ich ein Datum addieren kann, würde ich mich über ein kleines Beispiel freuen. Es muss darauf geachtet werden, dass die Tage auch in den nächsten Monat addiert werden können. Hier dürfte die Schwierigkeit liegen.

Danke im Voraus.

Patrick

Moin.

Probiers mal damit:


<?php
$add_tage = 4;
$dein_datum = "2006.01.01";
// Datum anhand der Punkte aufteilen
$datum_teile = explode (".", $dein_datum);
// $datum_teile[0] -> ist das Jahr
// $datum_teile[1] -> ist der Monat (???)
// $datum_teile[2] -> ist der Tag (???)

// dann das Datum in Timestamp umwandeln und $add_tage dazu addieren...
$timestamp_datum = mktime(0,0,0,$datum_teile[1],$datum_teile[2]+$add_tage,$datum_teile[0]);

// dann noch timestamp in dein Format umwandeln
$neues_datum = date("Y.m.d", $timestamp_datum );

// ausgabe
echo $neues_datum;
?>
[/PHP]

PS: Am besten das Datum immer in Timestamp umwandeln... dann kannste damit rechnen wie Du lustig bist.

Erstelle ein Konto oder melde dich an, um einen Kommentar zu schreiben.

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.