Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [php] dodawanie daty
Piotrwusek
post
Post #1





Grupa: Zarejestrowani
Postów: 399
Pomógł: 7
Dołączył: 11.06.2007
Skąd: Poznan

Ostrzeżenie: (20%)
X----


Witam

Dodaje do obecnej daty 7 dni!

  1. <?php
  2. $dni = 7;
  3. $data = date("Y-m-d");
  4. $wynik = date("Y-m-d",(strtotime($data) + (60*60*24*$dni)));
  5. ?>


$wynik to wynik (obecna data + 7 dni) a jak do $wynik dodać obecną godzinę-minutę-sekundę
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
artega
post
Post #2





Grupa: Zarejestrowani
Postów: 174
Pomógł: 42
Dołączył: 22.07.2007
Skąd: /dev/random

Ostrzeżenie: (0%)
-----


Czy nie prościej tylko raz obliczyć date?
  1. <?php
  2. $dni = 7;
  3. $wynik = date("Y-m-d H:i:s", time()+(60*60*24*$dni));
  4. ?>
Go to the top of the page
+Quote Post
Szupien
post
Post #3





Grupa: Zarejestrowani
Postów: 78
Pomógł: 0
Dołączył: 24.11.2007

Ostrzeżenie: (30%)
XX---


Cytat(artega @ 21.03.2008, 20:27:44 ) *
Czy nie prościej tylko raz obliczyć date?
  1. <?php
  2. $dni = 7;
  3. $wynik = date(&#092;"Y-m-d H:i:s\", time()+(60*60*24*$dni));
  4. ?>


It is not safe to rely on the system's timezone settings. Please use the date.timezone setting, the TZ environment variable or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Paris' for '1.0/no DST' instead
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 28.09.2025 - 21:12