laravel orm 字段时间戳 读取 变成时间格式
问题出现的环境背景及自己尝试过哪些方法
use CarbonCarbon; 在appserviceprovide加载过,去掉也不可以
相关代码
object(AppModelsUser)#1376 (28) {
["connection":protected]=>
string(5) "mysql"
["collection":protected]=>
string(10) "loan_users"
["dateFormat":protected]=>
string(1) "U"
["hidden":protected]=>
array(2) {
[0]=>
string(8) "password"
[1]=>
string(14) "remember_token"
}
["table":protected]=>
string(10) "loan_users"
["primaryKey":protected]=>
string(4) "uuid"
["incrementing"]=>
bool(false)
["keyType":protected]=>
string(3) "int"
["with":protected]=>
array(0) {
}
["withCount":protected]=>
array(0) {
}
["perPage":protected]=>
int(15)
["exists"]=>
bool(true)
["wasRecentlyCreated"]=>
bool(false)
["attributes":protected]=>
array(23) {
["id"]=>
int(211)
["uuid"]=>
string(36) "bffc1c50-3f25-11e9-93a8-09ef254ad03b"
["channel_id"]=>
string(24) "5c676692cfb7a400165bff37"
["phone"]=>
string(24) "SkUKpqv3yfsNTlWtXq8lZQ=="
["name"]=>
string(16) "网友1318252260"
["real_name"]=>
NULL
["id_card"]=>
NULL
["education"]=>
int(-1)
["house"]=>
int(-1)
["car"]=>
int(-1)
["icon_url"]=>
NULL
["password"]=>
string(60) "$2y$10$yVX0F5p1vCw/4y71kDXFqenKtIdVrFpRLn10HZCGNBQBpnhjRfa1C"
["is_black"]=>
int(1)
["status"]=>
int(1)
["activate"]=>
int(1)
["deleted_at"]=>
NULL
["add_time"]=>
int(1551776697)
["update_time"]=>
int(1552118408)
["occupation"]=>
string(3) "无"
["platform"]=>
int(0)
["encrypt_phone"]=>
string(64) "9d3ed35819d36711cc40b1d1c9c26e6ec556a65a062997fb82a05b7caaec8f39"
["encrypt_id_card"]=>
NULL
["registration_id"]=>
string(0) ""
}
["original":protected]=>
array(23) {
["id"]=>
int(211)
["uuid"]=>
string(36) "bffc1c50-3f25-11e9-93a8-09ef254ad03b"
["channel_id"]=>
string(24) "5c676692cfb7a400165bff37"
["phone"]=>
string(24) "SkUKpqv3yfsNTlWtXq8lZQ=="
["name"]=>
string(16) "网友1318252260"
["real_name"]=>
NULL
["id_card"]=>
NULL
["education"]=>
int(-1)
["house"]=>
int(-1)
["car"]=>
int(-1)
["icon_url"]=>
NULL
["password"]=>
string(60) "$2y$10$yVX0F5p1vCw/4y71kDXFqenKtIdVrFpRLn10HZCGNBQBpnhjRfa1C"
["is_black"]=>
int(1)
["status"]=>
int(1)
["activate"]=>
int(1)
["deleted_at"]=>
NULL
["add_time"]=>
int(1551776697)
["update_time"]=>
int(1552118408)
["occupation"]=>
string(3) "无"
["platform"]=>
int(0)
["encrypt_phone"]=>
string(64) "9d3ed35819d36711cc40b1d1c9c26e6ec556a65a062997fb82a05b7caaec8f39"
["encrypt_id_card"]=>
NULL
["registration_id"]=>
string(0) ""
}
["changes":protected]=>
array(0) {
}
["casts":protected]=>
array(0) {
}
["dates":protected]=>
array(0) {
}
["appends":protected]=>
array(0) {
}
["dispatchesEvents":protected]=>
array(0) {
}
["observables":protected]=>
array(0) {
}
["relations":protected]=>
array(0) {
}
["touches":protected]=>
array(0) {
}
["timestamps"]=>
bool(true)
["visible":protected]=>
array(0) {
}
["fillable":protected]=>
array(0) {
}
["guarded":protected]=>
array(1) {
[0]=>
string(1) "*"
}
["rememberTokenName":protected]=>
string(14) "remember_token"
}
这是直接读取里面的add_time
object(IlluminateSupportCarbon)#1397 (3) {
["date"]=>
string(26) "2019-03-05 17:04:57.000000"
["timezone_type"]=>
int(3)
["timezone"]=>
string(13) "Asia/Shanghai"
}
你期待的结果是什么?实际看到的错误信息又是什么?
下面单独打印也是时间戳
carbon 自动转化了,多读文档。