Welcome Guest, Not a member yet? Register   Sign In
having problem printing out "created_at" date
#1

This sound silly but I don't know what I'm doing wrong I just cant seem to echo out the  "created_at" & "updated_at" fields coming from the DB. Times stamps are created automatically using "protected $useTimestamps = true"

This is the loop

PHP Code:
if ($menu_list != null){
foreach (
$menu_list as $item) {
echo 
$item->name;
echo 
$item->created_at;
echo 
$item->updated_at;



Only the Name is printed. Now if I do print a single loop data on the array I get the below

PHP Code:
print_r($item); 


App\Entities\Admin\Menu\MenuData Object ( [datamap:protected] => Array ( ) [dates:protected] => Array ( [0] => created_at [1] => updated_at [2] => deleted_at ) [casts:protected] => Array ( ) [castHandlers:protected] => Array ( ) [defaultCastHandlers:CodeIgniter\Entity\Entity:private] => Array ( [array] => CodeIgniter\Entity\Cast\ArrayCast [bool] => CodeIgniter\Entity\Cast\BooleanCast [boolean] => CodeIgniter\Entity\Cast\BooleanCast [csv] => CodeIgniter\Entity\Cast\CSVCast [datetime] => CodeIgniter\Entity\Cast\DatetimeCast [double] => CodeIgniter\Entity\Cast\FloatCast [float] => CodeIgniter\Entity\Cast\FloatCast [int] => CodeIgniter\Entity\Cast\IntegerCast [integer] => CodeIgniter\Entity\Cast\IntegerCast [json] => CodeIgniter\Entity\Cast\JsonCast [object] => CodeIgniter\Entity\Cast\ObjectCast [string] => CodeIgniter\Entity\Cast\StringCast [timestamp] => CodeIgniter\Entity\Cast\TimestampCast [uri] => CodeIgniter\Entity\Cast\URICast ) [attributes:protected] => Array ( [menu_id] => 26 [comp_id] => 20002 [name] => Appetizers [image] => 20210905162616247.jpg [edited_by] => 0 [created_at] => 2021-09-05 16:25:34 [updated_at] => 2021-09-05 16:26:17 ) [original:protected] => Array ( [menu_id] => 26 [comp_id] => 20002 [name] => Appetizers [image] => 20210905162616247.jpg [edited_by] => 0 [created_at] => 2021-09-05 16:25:34 [updated_at] => 2021-09-05 16:26:17 ) [_cast:CodeIgniter\Entity\Entity:private] => 1 )

So I can see the data, but why can't it print  Confused
Reply


Messages In This Thread
having problem printing out "created_at" date - by chakycool - 09-05-2021, 05:53 AM



Theme © iAndrew 2016 - Forum software by © MyBB