模型"类型转换"对时间戳的优化

浏览:2155 发布日期:2017/09/11
类型转换为"timestamp"时,在正常的业务场景下某个字段暂时用0值代替,直到业务完成才会填入正确的时间戳(例如付款时间,退货时间等),而在业务完成前也可能需要获取该条数据,但因为值为0而产生了"1970-01-01 08:00:00",因此建议                if (!is_null($value)) {
                    $format = !empty($param) ? $param : $this->dateFormat;
                    $value  = $this->formatDateTime($value, $format);
                }
改为                if (!is_null($value)) {
                    $format = !empty($param) ? $param : $this->dateFormat;
                    $value  = !empty($value) ? $this->formatDateTime($value, $format) : '';
                }
评论(
后面还有条评论,点击查看>>