|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2007-07-19 04:26 UTC] lkc at pobox dot sk
Description: ------------ Using cURL with COOKIEJAR option resets timezone setting to GMT. This only occurs if: 1. The default timezone is set using date.timezone in php.ini, NOT through date_default_timezone_set(). 2. The cookie file contains timestamp(s). Reproduce code: --------------- echo date_default_timezone_get(), "\n"; $ch = curl_init(); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_COOKIEJAR, "cookie.txt"); curl_setopt($ch, CURLOPT_URL, "http://www.google.com"); $f = curl_exec($ch); curl_close($ch); echo date_default_timezone_get(), "\n"; Expected result: ---------------- Show identical timezones. Actual result: -------------- Second timezone is always GMT. PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 19:00:01 2025 UTC |
I can reproduce this under Windows XP. (It appears to be a Windows-only bug.) Further info: The only way to reproduce this is if the timezone is set via the date.timezone setting in php.ini. The bug does NOT occur when the TZ env var is set via put_env(), nor when date_default_timezone_set() is called from the script. The workaround is to do either of those things before calling curl_setopt(CURLOPT_COOKIEJAR);. Somehow DATEG(timezone) is being unset and the TZ env var populated with 'GMT', regardless of the timezone on the client. The TZ env var is populated during libcurl configuration (tzset() is called after putenv('TZ=whatever')). That's the only place in the entire libcurl source it's used, given that the libcurl shipped with PHP doesn't have IDNA support. Neither tzset() nor putenv() is called in ext/curl. At runtime, the TZ env var is only populated when CURLOPT_COOKIEJAR is set (not for CURLOPT_COOKIESESSION). I've no idea why, much less why setting TZ should interfere with PHP's global datetime values.