Bouncy Melons 0.1
declarative style orm
DatetimeField.php
Go to the documentation of this file.
1 <?php
2 
3 namespace bm;
4 
5 class DatetimeField extends Field{
6  const DEFAULT_SQL_TYPE = "datetime";
7 
8  public function beforeSet($value, ISingle $single) {
9  return date('Y-m-d H:i:s',strtotime($value));
10  }
11 
12  public function beforeGet($value, ISingle $single) {
13  $val = parent::beforeGet($value, $single);
14  $format = $this->getOption('format');
15  if(empty($format)) {
16  $format = "Y-m-d H:i:s";
17  }
18  return date($format,strtotime($value));
19  }
20 }
beforeGet($value, ISingle $single)
beforeSet($value, ISingle $single)