Model类类型转换timestamp和datetime调整

This commit is contained in:
thinkphp
2016-06-19 15:42:05 +08:00
parent bfddad2a61
commit d213339dbd

View File

@@ -301,12 +301,12 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
case 'boolean':
$value = (bool) $value;
break;
case 'datetime':
case 'timestamp':
if (!is_numeric($value)) {
$value = strtotime($value);
}
break;
case 'timestamp':
case 'datetime':
$format = !empty($param) ? $param : $this->dateFormat;
$value = date($format, is_numeric($value) ? $value : strtotime($value));
break;
@@ -382,11 +382,11 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
case 'boolean':
$value = (bool) $value;
break;
case 'datetime':
case 'timestamp':
$format = !empty($param) ? $param : $this->dateFormat;
$value = date($format, $value);
break;
case 'timestamp':
case 'datetime':
$format = !empty($param) ? $param : $this->dateFormat;
$value = date($format, strtotime($value));
break;