经过几次这样的尝试,我试图更改Joomla 3 DB表的日期格式
echo date_format("end_date", "%d/%m/%Y");
echo $result->format('$result->end_date', 'd-m-Y');
// also tried to get kind of result March 10, 2001, 5:16 pm
echo date_format("end_date", "F j, Y, g:i a");
echo date_format("$result->end_date", "F j, Y, g:i a");
echo date_format('$result->end_date', 'F j, Y, g:i a');
echo date_format({$result->end_date}, 'F j, Y, g:i a');
echo date($result->end_date}, 'F j, Y, g:i a');
echo date('$result->end_date', 'F j, Y, g:i a');
echo "<time datetime='$result->end_date'>" "</time>";
,检查了堆栈溢出的所有相关帖子,以查找类似类型的代码,所有课程和示例,但无法将此end_date格式更改为d / m / Y
<?php
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$select = array(
$db->quoteName('title'),
$db->quoteName('id'),
$db->quoteName('start_date'),
$db->quoteName('end_date')
);
$query->select(array($select));
$query->from($db->quoteName('#__rbid_auctions'));
$query->order($db->quoteName('id') . " DESC");
$query->setLimit(3);
$db->setQuery($query);
$results = $db->loadObjectList();
// display the results
foreach ( $results as $result) {
echo "<a href=\"index.php?option=com_rbids&task=viewbids&id={$result->id}\">{$result->title} . </a>";
echo "<p>" . $result->start_date . "</p>";
echo "<p>" . $result->end_date . "</p>";
}
?>
预先感谢
答案 0 :(得分:1)
尝试使用以下内容:
// instantiate a new Joomla Date Object
$date = new JDate($result->start_date);
// echo the formatted date
echo $date->format('F j, Y, g:i a');
希望有帮助,
Gez