Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [MySQL][PHP]data wpisana mimo że jest pusta
neurogen
post
Post #1





Grupa: Zarejestrowani
Postów: 58
Pomógł: 0
Dołączył: 25.03.2018

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


pole w bazie mysql daty urodzenia jest NULL ale pobrana przez php wartość pola wyświetla datę jako 01-01-1970. jak to naprawić?
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
Neutral
post
Post #2





Grupa: Zarejestrowani
Postów: 286
Pomógł: 46
Dołączył: 10.01.2016

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


  1. $zone = new DateTimeZone('Europe/Warsaw');
  2. $timestamp = new DateTime(null, $zone);
  3. $timestamp_val = $timestamp->getTimestamp();
  4. //$timestamp_val = null;
  5.  
  6. if(!is_null($timestamp_val)) {
  7. var_dump($timestamp->setTimestamp($timestamp_val)->format('H:i:s'));
  8. } else {
  9. // here insert any sequence
  10. }
  11.  


Może jest w jakiejś klasie daty i/lub czasu coś co ustawia automatycznie datę i/lub czas, kiedy user poda null'a, ale musiałbyś sprawdzić.

http://php.net/manual/en/book.datetime.php

Ten post edytował Neutral 13.12.2018, 03:06:33
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: 15.10.2025 - 05:50