我遇到了有关事件日期的奇怪问题,并且我尽力使其得到解决,但无法完成。省略日期范围列表中的冗余月份和年份
我附上的我多么想在页面上显示的日期的截图:
在图片中AKTION第一事件Deine科特布斯!是5个事件的组合,每个事件都有其开始日期和结束日期。
活动的第一部分是1日活动,活动从4月4日开始,到4月4日结束。第二部分同样在4月7日,4月9日第3部分和4月20日第4部分
最后一部分从5月5日开始到5月10日结束。
日期以这种格式存储在数据库中: 我正在显示事件的最后部分的日期。 活动开始日期:2013年5月5日00:00:00 活动结束日期:2013年5月10日00:00:00
所以我想显示在图片中显示的日期格式。
有多种情况: 首先,如果所有日期都在一个月内发生,那么我们只在最后一次显示月份名称。 二是如果月份发生变化,月份名称将在月份更改日期之后显示。
我在while循环中获取事件日期,所以如何将当前事件日期与循环中即将到来的事件日期进行比较。
这是迄今为止我已经习惯了从数据库中获取日期的代码..
$nid = $row->nid;
$get_product_id = "SELECT product_id from {uc_product_kits} where nid='$nid'";
$res = db_query($get_product_id);
while ($get_product_id_array_value = db_fetch_array($res)) {
$prductid = $get_product_id_array_value['product_id'];
$start_date = db_query("select event_start,event_end from {event} where nid=%d",$prductid);
$start_date_value = db_fetch_object($start_date);
$end_value = $start_date_value->event_start;
$event_end_date = $start_date_value->event_end;
$TotalStart = date("d M Y", strtotime($end_value));
$TotalEnd = date("d M Y", strtotime($event_end_date));
$onlyMonthStart = date("M", strtotime($end_value));
$onlyMonthEnd = date("M", strtotime($event_end_date));
//$groupMonth = db_query("select event_start,event_end, month from {event} where nid=%d group by ",$prductid);
if($TotalStart == $TotalEnd){
$startDay = date("d", strtotime($end_value));
$startMonth = date("M", strtotime($end_value));
if(in_array($startMonth,$newMonth)) {
echo $onlstartdate;
}
else {
$onlstartdate = date("d", strtotime($end_value));
echo $onlstartdate;
$tempStorage[] = $startMonth
}
//$newMonth[] = $startMonth;
}
}
我已经更新了我的一些示例代码的答案。 – 2013-04-18 09:44:33
谢谢马丁。这对我有效。 – 2013-04-18 12:41:47
不客气。快乐,它帮助你。 – 2013-04-18 12:46:52