Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid requiring PHP's timezone settings to be set #18

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

binki
Copy link
Contributor

@binki binki commented Dec 23, 2011

PHP makes a lot of notice noise when it hits the strtotime() function and the user hasn't set a timezone. This is because there's a chance that the string being parsed is not a UTC-formatted date. I think that since S3 only gives out dates in UTC, PHP is being silly in requiring that a timezone be set. However, there is no utcstrtotime() function provided by PHP which would be happy to parse timezone-independent (i.e., UTC) dates into unix timestamps.

These two commits avoid this issue. The first uses libcurl's own date parsing for handling an HTTP response's Last-Modified header. The second locally uses a UTC DateTimeZone object when parsing dates stored in the XML documents.

…hen parsing UTC dates.

This is done by avoiding calls to strtotime(). Instead, a DateTimeZone object
with UTC set as its timezone is created. When this object is passed to DateTime's
constructor, PHP is pacified by being given the timezone context even though
it isn't consulted.
@tpyo
Copy link
Owner

tpyo commented Jan 20, 2012

Thanks for this. Just got back from holiday so still trying to catch up! Will examine, test and hopefully merge soon.

@iazi
Copy link

iazi commented Jul 20, 2012

Totally agree with that one

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants