Category: MySQL, api

I recently ran into an issue where I was getting integer value timestamp data from an API which I simply saved into an integer column of a table. The client I was working with then decided that they needed to the integer column of timestamps to be converted into human readable DateTime.

After Googling around for quite some time I finally found an answer that worked which I think is worth sharing.

In mysql t able run one of the following queries depending on your use case: You have a 10 digit timestamp value e.g.

Then FLOOR is appliedwhich converts the number to an integer (which is what we need in the next step) by rounding down.
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge. Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge.
Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Shirts painstakingly handcrafted by under-caffeinated developers. Shirts painstakingly handcrafted by under-caffeinated developers.
Community Partners