Turn Sequence of Numbers into Data with PHP and SQL

Asked

Viewed 525 times

1

I have a database that has a numerical sequence recorded in a table that means a publication date of an article. I wonder if someone can decipher this numerical sequence so I can print the correct date through PHP.

For example:

1464880280 = 02/06/2016
1465580280 = 10/06/2016
1466513100 = 21/06/2016

Someone can decipher and help me create a function to display this converted date?

2 answers

5

This numeric sequence is the date in UNIX Timestamp format. There is already a function for conversion.

Example in php:

echo date('d/m/Y', 1464880280);
echo date('d/m/Y', 1465580280);
echo date('d/m/Y', 1466513100);

For more information access.

3

You can also format in Mysql using FROM_UNIXTIME and DATE_FORMAT:

Example:

SELECT DATE_FORMAT(FROM_UNIXTIME(1464880280),'%d/%m/%Y %H:%i') as dt;

Browser other questions tagged

You are not signed in. Login or sign up in order to post.