leostereo's avatar

getting timestamp weird format

Hi guys, im facing a strange behaviour: Im retriving some timestamps stored on my db doing:

 $registers = Fichajes::all()->toArray();
 $msg="Registros: \n";

                        foreach($registers as $register){
                                $msg .= $register['created_at'].' '.$register['type']."\n";
                        }
        
return urlencode($msg);

If I look at my Fichajes table , it looks like:

+----+---------------------+---------------------+---------+--------+
| id | created_at          | updated_at          | user_id | type   |
+----+---------------------+---------------------+---------+--------+
|  3 | 2020-03-22 17:49:38 | 2020-03-22 17:49:38 |       7 | begin  |
|  4 | 2020-03-22 18:03:03 | 2020-03-22 18:03:03 |       7 | finish |
|  5 | 2020-03-22 18:25:18 | 2020-03-22 18:25:18 |       7 | salida |
+----+---------------------+---------------------+---------+--------+

But when I bring the data , they looks like:

2020-03-22T17:49:38.000000Z begin
2020-03-22T18:03:03.000000Z finish
2020-03-22T18:25:18.000000Z salida
2020-03-22T18:26:21.000000Z salida
2020-03-22T18:26:27.000000Z entrada

How can I avoid those '000000Z' strings on my data ? Regards. Leandro

0 likes
5 replies
leostereo's avatar

Hi shez1983. My version:

[root@SRV_Redes fichajes]# php artisan --version
Laravel Framework 7.2.2

It worked !!!! Thanks.

1 like
Jael's avatar

Thanks! This help a lot with a project! Very useful!

1 like
ginlove0's avatar

Thanks, shez1983. That's saved my day.

1 like
wall-e's avatar

I was exactly looking for the method in that documentation link. Thank you for mentioning it! @shez1983

1 like

Please or to participate in this conversation.