PHP显示查询不同的sql执行

config.php

@$mysqli= mysqli_connect($servername, $username_bd, $password_bd, $dbname);
if($mysqli->connect_error)
    return false;

insert.php

include 'config.php';        
$DateDefault = '2015-07-30 00:00:00
2015-08-30 00:00:00';

 $sql = "INSERT INTO users (date) VALUES ('$DateDefault')";        
   if($query = $mysqli->query($sql)===true)
       echo "Date add successfully";
   else
       echo "Error into date";

show.php

include 'config.php';

$sql = "SELECT date FROM users WHERE username='$username'";
$query = $mysqli->query($sql);
if (@$query->num_rows > 0){
    while ($dados = $query->fetch_assoc()) { 
        echo substr($dados['date'], 21, 19);
    }
}

Result: "2015-08-30 00:00:00"

Now, when I changed the date in the phpmyadmin, for

"2015-07-30 00:00:00
2015-09-30 00:00:00"

Shows this:

"015-09-30 00:00:00 "

In localhost, using wampserver, this bug don't happen

Your issue is likely to do with how different operating systems treat line endings. In a nutshell, on Windows, line endings take up two characters (carriage return and newline, ), and on most other operating systems, they occupy only one (newline, ). By using specific character offsets, you're introducing the possibility of the off-by-one error you're seeing.

A simple fix would be to separate your dates by using a single space (or another character) instead of a line break. If you still want to use a line break, you can split the string by whitespace:

$dates = preg_split('/\s+/', $dados['date']); // Split dates by whitespace
echo $dates[1]; // Print the second date