简体   繁体   English

Codeigniter日历库显示星期和月份

[英]Codeigniter calendar library to display week and month

i'm searching a way to display data for week and month. 我正在寻找一种显示每周和每月数据的方法。

For now, i can click on a day of the calendar and see the data related to this day. 现在,我可以单击日历的某一天,然后查看与这一天相关的数据。

For example, i'd like to choose the week number 5(or a month) of year 2013 and see the data related. 例如,我想选择2013年的第5周(或一个月),并查看相关数据。

Any idea of how to do it? 有什么想法吗?

Thank you. 谢谢。

i found out the solution: 我找到了解决方案:

My controller script: 我的控制器脚本:

$p = new DatePeriod(
new DateTime('2013-09-01'), 
new DateInterval('P1W'), 
new DateTime($today)
);
$data['weeks'] = array();
$data['month'] = array();
foreach ($p as $w) {
$data['weeks'][$w->format('W')] = $w->format('Y').' - Week '.$w->format('W');
$data['month'][$w->format('m')] = $w->format('Y').' - Month '.$w->format('m');
}

My view script: 我的视图脚本:

<?php
// display for weeks
echo form_dropdown('week', $weeks, $lastWeek);
// display for month
echo form_dropdown('month', $month, $lastMonth);
?>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM