Skip to content

Instantly share code, notes, and snippets.

@violetyk
Created November 17, 2011 07:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save violetyk/1372623 to your computer and use it in GitHub Desktop.
Save violetyk/1372623 to your computer and use it in GitHub Desktop.
[cakephp]ScheduleBehaviorでまだできないこと
<?php
// 今のところエディット時にパースして日付と時間をわけないとだめ。
if (empty($this->data)) {
$this->Content->Behaviors->detach('Schedule');
$this->data = $this->Content->read(null, $id);
$published = date_create($this->data['Content']['published']);
if($published != null) {
$this->data['Content']['published_date'] = date_format($published, 'Y-m-d');
$this->data['Content']['published_time'] = date_format($published, 'H:i:s');
}
$unpublished = date_create($this->data['Content']['unpublished']);
if($unpublished != null) {
$this->data['Content']['unpublished_date'] = date_format($unpublished, 'Y-m-d');
$this->data['Content']['unpublished_time'] = date_format($unpublished, 'H:i:s');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment