How to get the right "date" from MySQL through PHP.



  • It is now reflection of this type:

    введите сюда описание изображения

    You need to:

    введите сюда описание изображения

    <?php
      $mysqli = @new mysqli('localhost', 'root', 'vertrigo', 'rues');
      if (mysqli_connect_errno()) {
        echo "Подключение невозможно: ".mysqli_connect_error();
      }
      $result_set = $mysqli->query('SELECT * FROM news');
      while ($row = $result_set->fetch_assoc()) {
        echo "<div id='ctitle'>". $row['title'] ."</div>";
        echo "<div id='news'>". $row['text'] ."</div>";
        echo $row['date'];
      }
      $result_set->close();
      $mysqli->close();
    ?>
    

    Result: введите сюда описание изображения

    The answer was received, thank you for your help.



  • $date = date_create($row["date"]);
    echo date_format($date, 'F d,Y - G:H');
    

    The format of the details http://php.net/manual/ru/function.date.php ♪
    But round 12:45 to 1 p.m., if that's the same thing, you've got to go with your hands.




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2