入住 CI 中国社区 登录
CodeIgniter 中国开发者社区 返回首页

382148374的个人空间 https://codeigniter.org.cn/forums/?14902 [收藏] [复制] [分享] [RSS]

日志

日历

已有 1308 次阅读2012-6-4 15:46 | 日历

/**
* 返回日历上的存档链接
* @access public
* @param integer $year
* @param integer $month
* @return array
*/

public function get_calendar_data($year, $month)
{
 
$time_start = mktime(0, 0, 0, $month, 1, $year);
 
$time_end = mktime(0, 0, 0, $month+1, 1, $year);
 
$this->db->select('create_date');
 
$this->db->from('news');
 
$this->db->where('create_date >=', $time_start);
 
$this->db->where('create_date <', $time_end);
 
$cal_res = $this->db->get()->result_array();
 
 
$cal_url = array();
 
foreach(array_keys($cal_res) as $key)
 
{
 
$cal_date = $cal_res[$key]['create_date'];
 
$cal_url[date('j', $cal_date)] = site_url('news/article/'.date('Y/n/', $cal_date));
 
}
 
return $cal_url;
}

路过

雷人

握手

鲜花

鸡蛋

评论 (0 个评论)

facelist doodle 涂鸦板

您需要登录后才可以评论 登录 | 入住 CI 中国社区