Home » Php » php – get_dir_file_info date returned not readable

php – get_dir_file_info date returned not readable

Posted by: admin February 25, 2020 Leave a comment


So I used the get_dir_file_info function of Codeigniter to get the file details inside a directory

The function returns an array like this:

name: "file.sql"
server_path: "filepath\file.sql"
size: 22055
date: 1581558753
relative_path: "filepath/"

I can’t understand the date returned by the function. How do I convert it to a readable date?

How to&Answers:

use just a simple date() function like given below:

echo date("Y-m-d H:i:s", 1581558753);


This is a UNIX timestamp. It is the number of seconds that have elapsed since the Unix epoch, that is the time 00:00:00 UTC on 1 January 1970, minus leap seconds. There are many ways to convert this to an ordinary date or vice versa.




For converting UNIX time to common date:

 date("Y/m/d H:i:s" , 1581558753); //Result=>2020/02/13 1:52:33

For converting date to UNIX timestamp:

 strtotime("3 October 2005"); //Result =>1128297600


 mktime(0,0,0,10,3,2005);  //Result =>1128297600