में दिनांक का अप्रत्याशित व्यवहार मैं लार्वेल में एक वेब सेवा कर रहा हूं जो JSON लौटा रहा है। अपेक्षा के अनुरूपलैरवेल: JSON प्रतिक्रिया
class Account extends Eloquent {
// The database table used by the model.
// (If not defined then lowercase and plural of class name is consider as a table name)
protected $table = "account";
// define which column can be mass assign
protected $fillable = array("user_id", "account_group_id", "generated_by", "image", "name",
"address", "zip", "area_id", "mobile", "email", "phone", "fax",
"website", "pan", "cst", "tin", "ecc", "iesc", "transport",
"other", "outstanding", "cform", "status", "mitp");
// To prevent column from mass assignment.
protected $guarded = array('id');
// Change Variable for CREATED_AT and UPDATED_AT
const CREATED_AT = 'itp';
const UPDATED_AT = 'utp';
}
मैं Account
से खेतों को लाते समय हूँ user_id
का उपयोग कर और मेरे नियंत्रक
$accountData = Account::select('name', 'status', 'id', 'user_id', 'utp')->where('user_id', Auth::id())->first();
$return = array(
'result' => 'success',
'msg' => 'Login Successfully.',
'data' => $accountData
);
return Response::json($return);
इस में, utp
बर्ताव में Response::json()
के माध्यम से JSON लौटने:
मैं बहुत की तरह एक Account
मॉडल बनाया है और एक स्ट्रिंग के रूप में एक तिथि देता है:
{
"result": "success",
"msg": "Login Successfully.",
"data": {
"name": "Demo",
"status": 0,
"id": 143,
"user_id": 207,
"utp": "2015-07-01 18:38:01"
}
}
लेकिन अगर मैं इतना की तरह खाते मॉडल से अलग मान ले:
$return = array(
'result' => 'success',
'msg' => 'Login Successfully.',
'data' => $accountData['user_id'],
'account_id' => $accountData['id'],
'utp' => $accountData['utp'],
'usertype' => 'account',
'status' => $accountData['status']
);
फिर इस से utp
{
"result": "success",
"msg": "Login Successfully.",
"data": 207,
"account_id": 143,
"utp": {
"date": "2015-07-01 18:38:01",
"timezone_type": 3,
"timezone": "Asia\\/Kolkata"
},
"usertype": "account",
"status": 0
}
कुछ अनपेक्षित व्यवहार देता है क्यों यह मेरा टाइमस्टैम्प क्षेत्र के साथ होता है?