Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP] Czas co 10 minut
brzanek
post
Post #1





Grupa: Zarejestrowani
Postów: 429
Pomógł: 0
Dołączył: 8.11.2012

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


Witam mam problem potrzebuję uzyskać czas w formie RRRR-MM-DD_hh_mm_ss
Mam taki kod
  1. <?php
  2. $today = date('Y-m-d H00');
  3. for($i=1; $i<=11; $i++)
  4. {
  5. $repeat = strtotime("+10 minute",strtotime($today));
  6. $today = date('Y-m-d Hi',$repeat);
  7. echo $today;
  8. }
  9. ?>

Pojawia mi się taki wynik
2022-11-20 11:102022-11-20 11:202022-11-20 11:302022-11-20 11:402022-11-20 11:502022-11-20 12:002022-11-20 12:102022-11-20 12:202022-11-20 12:302022-11-20 12:402022-11-20 12:50
czyli taka forma RRRR-MM-DD hh:mm:ss a chcę aby było to w formie RRRR-MM-DD_hh_mm_ss
Czy jest to możliwe?

Ten post edytował brzanek 20.11.2022, 13:03:37
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
slid3r
post
Post #2





Grupa: Zarejestrowani
Postów: 17
Pomógł: 0
Dołączył: 15.12.2021

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


możne się przyda


  1.  
  2. <script>
  3. function renderTime() {
  4. var currentTime = new Date();
  5. var diem = "AM";
  6. var h = currentTime.getHours();
  7. var m = currentTime.getMinutes();
  8. var s = currentTime.getSeconds();
  9. setTimeout('renderTime()',1000);
  10. if (h == 0) {
  11. h = 12;
  12. } else if (h > 12) {
  13. h = h - 12;
  14. diem="PM";
  15. }
  16. if (h < 10) {
  17. h = "0" + h;
  18. }
  19. if (m < 10) {
  20. m = "0" + m;
  21. }
  22. if (s < 10) {
  23. s = "0" + s;
  24. }
  25. var myClock = document.getElementById('clockDisplay');
  26. myClock.textContent = h + ":" + m + ":" + s + " " + diem;
  27. myClock.innerText = h + ":" + m + ":" + s + " " + diem;
  28. }
  29. renderTime();
  30. </script>
  31.  
  32.  
Go to the top of the page
+Quote Post

Posty w temacie


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

 



RSS Aktualny czas: 7.10.2025 - 05:03