本文整理汇总了PHP中date::time_24h方法的典型用法代码示例。如果您正苦于以下问题:PHP date::time_24h方法的具体用法?PHP date::time_24h怎么用?PHP date::time_24h使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类date
的用法示例。
在下文中一共展示了date::time_24h方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: time
/**
* Validate time
*
* @param int|string $time
* @return bool
*/
public static function time($time)
{
return (bool) date::time_24h($time);
}
示例2: _event_edit
/**
* Edit event
*
* @param int|string $event_id
*/
public function _event_edit($event_id = false)
{
$this->history = false;
$event = new Event_Model((int) $event_id);
// For authenticated users only
if (!$this->user || !$event->is_author() && !$this->visitor->logged_in(array('admin', 'event moderator'))) {
url::back('/events');
}
$errors = $form_errors = array();
$form_values = $event->as_array();
$form_values['start_date'] = '';
$form_values['start_hour'] = '';
$form_values['end_hour'] = '';
/***** CHECK POST *****/
if (request::method() == 'post') {
$post = array_merge($this->input->post(), $_FILES);
$extra = array('start_time' => date::unix2sql(strtotime($post['start_date'] . ' ' . date::time_24h($post['start_hour']))));
if (!empty($post['end_hour'])) {
$end_time = strtotime($post['start_date']);
// end hour is earlier than start hour = event ends the next day
if ($post['end_hour'] < $post['start_hour']) {
$end_time = strtotime('+1 day', $end_time);
}
$extra['end_time'] = date('Y-m-d', $end_time) . ' ' . date::time_24h($post['end_hour']) . ':00';
}
// update
$editing = (bool) $event->id;
if ($editing) {
$extra['modified'] = date::unix2sql(time());
$extra['modifies'] = (int) $event->modifies + 1;
} else {
$extra['author_id'] = $this->user->id;
}
$city = ORM::factory('city', $post['city_id']);
if ($city) {
$extra['country_id'] = $city->country_id;
}
if (csrf::valid() && $event->validate($post, true, $extra)) {
// Update tags
$event->remove(ORM::factory('tag'));
if (!empty($post['tags'])) {
foreach ($post['tags'] as $tag_id => $tag) {
$event->add(ORM::factory('tag', $tag_id));
}
$event->save();
}
// Handle flyer uploads
foreach (array('flyer_front_image_id' => $post->flyer_front, 'flyer_back_image_id' => $post->flyer_back) as $image_id => $flyer) {
if (isset($flyer) && empty($flyer['error'])) {
$image = Image_Model::factory('events.flyer', $flyer, $this->user->id);
if ($image->id) {
$event->add($image);
$event->{$image_id} = $image->id;
$event->save();
}
}
}
if (!$editing) {
newsfeeditem_events::event($this->user, $event);
}
url::redirect(url::model($event));
} else {
$form_errors = $post->errors();
}
$form_values = arr::overwrite($form_values, $post->as_array());
}
/***** /CHECK POST *****/
/***** SHOW FORM *****/
if ($event->id) {
$this->page_actions[] = array('link' => url::model($event) . '/delete/?token=' . csrf::token(), 'text' => __('Delete event'), 'class' => 'event-delete');
$this->page_title = text::title($event->name);
$this->page_subtitle = __('Edit event');
list($form_values['start_date'], $form_values['start_hour']) = explode(' ', date('Y-m-d H', strtotime($event->start_time)));
if (!empty($event->end_time)) {
list($temp, $form_values['end_hour']) = explode(' ', date('Y-m-d H', strtotime($event->end_time)));
}
} else {
$this->page_title = __('New event');
}
$form = $event->get_form();
// Tags
if ($tag_group = Kohana::config('events.tag_group')) {
$form['tags'] = $form_values['tags'] = array();
$tags = ORM::factory('tag_group', $tag_group);
foreach ($tags->tags as $tag) {
$form['tags'][$tag->id] = $tag->name;
if ($event->has($tag)) {
$form_values['tags'][$tag->id] = $tag->name;
}
}
}
// City autocomplete
$this->_autocomplete_city('city_name');
// Venue autocomplete
$venues = ORM::factory('venue')->where('event_host', '=', 1)->find_all();
//.........这里部分代码省略.........