gpt4 book ai didi

PHP 回显空白日期时间字段

转载 作者:行者123 更新时间:2023-11-29 07:10:47 26 4
gpt4 key购买 nike

这是我的困境。我尝试引用 http://php.net/manual/en/datetime.format.php

但这对我没有帮助,或者我没有正确设置我的代码。

这是我的代码。

$query =  "SELECT id,f_name, l_name, phone_1, phone_2, car_name, email, zipcode, ref_name, dateadded ";
$query .= "FROM customers JOIN carriers ON customers.carrier = carriers.car_id ";
$query .= "JOIN referrals ON customers.referral = referrals.ref_id";

$select_customers = mysqli_query($connection, $query);

while($row = mysqli_fetch_assoc($select_customers)) {
$customer_id = $row['id'];
$c_fname = $row['f_name'];
$c_lname = $row['l_name'];
$c_email = $row['email'];
$c_phone1 = $row['phone_1'];
$c_phone2 = $row['phone_2'];
$car_id = $row['car_id'];
$c_carrier = $row['car_name'];
$c_zip = $row['zipcode'];
$ref_id = $row['ref_id'];
$c_ref = $row['ref_name'];
$c_added = $row['dateadded'];

echo "<tr>";
echo "<td>{$c_fname}</td>";
echo "<td>{$c_lname}</td>";
echo "<td>{$c_email}</td>";
echo "<td>{$c_phone1}</td>";
echo "<td>{$c_phone2}</td>";
echo "<td>{$c_carrier}</td>";
echo "<td>{$c_zip}</td>";
echo "<td>{$c_ref}</td>";
echo "<td>". date_format($c_added, 'd/m/y') ."</td>";
echo "<td><a class='btn btn-danger' href='customers.php?source=edit_customer&id={$customer_id}'>Edit</a></td>";
}

它将回显一个空白字段。 “dateadded”的 col 设置为“2016-09-28 10:40:44”的日期时间。感谢对我的代码的更正。谢谢。

最佳答案

有很多方法可以做到这一点,这是之前答案的另一种方法:

echo "<td>". date_format(new DateTime($c_added), 'd/m/y') ."</td>";

关于PHP 回显空白日期时间字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39811107/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com