Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Jak odczytać datę w formacie Date(1475791200000-0000)
doktorek
post
Post #1





Grupa: Zarejestrowani
Postów: 32
Pomógł: 0
Dołączył: 26.07.2010

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


Jak w temacie...

XML zwraca mi datę w takim formacie...
Próbowałem różnych konwersji i nic nie daje...

Date(1475791200000-0000)

Jak to przerobić na zwykłą datę ?

Pozdrawiam
DOK
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
Puszy
post
Post #2





Grupa: Zarejestrowani
Postów: 279
Pomógł: 42
Dołączył: 10.10.2011

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


  1. <?php
  2.  
  3. /**
  4.  * @param string $xmlTimestamp
  5.  * @return \DateTime
  6.  */
  7. function getDateTime($xmlTimestamp){
  8. $timestamp = intval(substr(str_replace('-0000', '', $xmlTimestamp), 0, -3));
  9.  
  10. $date = new DateTime();
  11. $date->setTimestamp($timestamp);
  12.  
  13. return $date;
  14. }
  15.  
  16. print_r(getDateTime('1475791200000-0000'));
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: 16.10.2025 - 13:34