[PHP-NOTES] note 130398 added to datetime.format

[email protected] ("[email protected]") Tue, 1 Jul 2025 13:39:11 +0000 (UTC)
Newsgroups php.notes
Message-ID <[email protected]>
# If you want the return of data in the array to be formatted directly in the return.

public function toArray($keyName)
    {
        return [
             'category' => $keyName,
             'description_add' => $this->description,
             'created_at' => $this->created_at->format('Y-m-d H:i:s'),
     ];
}

Return:
"result": {
        "category": "DOCUMENTATION",
        "description_add": "Rejected for internal reasons.",
        "created_at": "2025-07-01 10:25:27"
}
----
Server IP: 45.112.84.4
Probable Submitter: 45.112.84.18 (proxied: 186.236.94.226)
----
Manual Page -- https://php.net/manual/en/datetime.format.php
Edit        -- https://main.php.net/note/edit/130398
Del: integrated  -- https://main.php.net/note/delete/130398/integrated
Del: useless     -- https://main.php.net/note/delete/130398/useless
Del: bad code    -- https://main.php.net/note/delete/130398/bad+code
Del: spam        -- https://main.php.net/note/delete/130398/spam
Del: non-english -- https://main.php.net/note/delete/130398/non-english
Del: in docs     -- https://main.php.net/note/delete/130398/in+docs
Del: other reasons-- https://main.php.net/note/delete/130398
Reject      -- https://main.php.net/note/reject/130398
Search      -- https://main.php.net/manage/user-notes.php