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.
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.
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.