datetime - Unix Timestamp to PHP Year Month and Day Conversion Off -
we in process of moving our domain new dedicated server purchased. new server's time zone causing issues our attachments php code.
our forum software uses following folder structure store attachments:
/public_html/forum/files/2016/february/14/[filename]
the year, month , day obtained file upload time stamp unix timestamp such "1455426488". timestamp converted year, month , day using following php code:
$date = getdate((int)$attachment['filetime']); $filepath = $config['upload_path'] . '/' . (string)$date['year'] . '/' . $date['month'] . '/' . (string)$date['mday'];
this worked fine on our old server , server before it, on new server "day" either 1 day behind or 1 day ahead when converted, causes "february 14" file uploads either end in "february 13" folder or "february 15". keep in mind file upload time of 1455426488 in unix timestamp 02/14/2016 @ 5:08am utc timezone.
does have suggestions on how fix issue? critical part of our forum system, without coming solution won't able migrate new server.
thanks,
pete
btw, both old , new server using "america/chicago" timezone (cst).
you can use datetime class in order convert dates.
$date = new datetime(null, new datetimezone('america/chicago')); $date->settimestamp((int)$attachment['filetime']); $filepath = $config['upload_path'] . '/' . $date->format('y') . '/' . $date->format('f') . '/' . $date->format('d');
Comments
Post a Comment