Any ideas how I can make a simple IF-statement
that sort 31-10-2017
or 12-01-2016
from 1511431687
?
I am converting from a set date, to use unix timestamp, and need a solution to sort out what is what. I want to display the date in human readable format (days/ month/year).
So I have a $data
that is inside a loop. It pulls the date from a flat file. The old stuff has just saved the date as a date. For instance 31-10-2017
(exactly like that).
Now I use unix timestamp. For instance 1511431687
.
I see people have used a simple IF-statement, but I can not use it as both are 10 units long. Else that would have worked well.
$data = // either a timestamp, or a date in this format: 31-10-2017
if (strlen($data) === 10) // it's a timestamp
$data = date("d-m-Y H:i:s", $data);