Reputation: 1638
I'm trying to work out what format this date is in!
'date' => int 1342640973
Date today is 18.07.2012
I got it from the get_file_info function in the CI File Helper.
Upvotes: 0
Views: 1779
Reputation: 63797
The value you have represent a date/time in seconds since the first of January 1970 (in UTC), it's often referred to as a "unix timestamp" because of it's origin.
Handling this time representation is easily done in PHP, there are native functions made to convert back and to the format.
time ()
will return the current time in the format specified (unix timestamp), to convert this into a readable string you can use date
with the appropriate format-string, as in the below example:
$unix_timestamp = 1342640973;
$now_utimestamp = time ();
print_r (
array (
date ("Y-m-d G:i:s", $unix_timestamp),
date ("Y-m-d G:i:s", $now_utimestamp)
)
);
output on my system:
Array
(
[0] => 2012-07-18 21:49:33
[1] => 2012-07-18 22:18:43
)
Unless you have told PHP which timezone it's currently in (using php.ini or equivalent) you'll need to specify this using the function date_default_timezone_set()
, passing it the value of date_default_timezone_get()
will try to set it according to your system preferences.
If it's unable to find a correct match UTC will be used per default.
Upvotes: 2
Reputation: 7155
in codeigniter use
unix_to_human(TIMESTAMP)
to get the human readable date, it will require to include date helper
Upvotes: 0
Reputation: 24363
It's a unix timestamp, which is the number of seconds that have elapsed since midnight Coordinated Universal Time (UTC), January 1, 1970, not counting leap seconds.
To get the current timestamp in PHP, you can use time and to convert a timestamp into a human-readable format you can use date.
Upvotes: 3