laravelphp-carbon

Convert Unix Timestamp to Carbon Object


I have a Unix timestamp in a table and want to convert it to a human-readable format using Carbon. How can I achieve this?

e.g.

1487663764.99256
To
2017-02-24 23:23:14.654621

Solution

  • Did you check the carbon docs? I think this is what youre looking for:

    Carbon::createFromTimestamp(-1)->toDateTimeString(); 
    

    Checkout http://carbon.nesbot.com/docs/#api-instantiation