Adrian
Adrian

Reputation: 347

get_dir_file_info date returned not readable

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?

Upvotes: 0

Views: 81

Answers (2)

Farzad Rastgar Sani
Farzad Rastgar Sani

Reputation: 371

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.

Online

https://www.unixtimestamp.com/

PHP

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

or:

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

Upvotes: 0

sayalok
sayalok

Reputation: 920

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

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

Upvotes: 1

Related Questions