-
Notifications
You must be signed in to change notification settings - Fork 96
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
Exception causing trouble in PHP 5.2.13 #5
Comments
You are correct, last day of wasn't added until 5.3 according to the comments on http://us.php.net/manual/en/datetime.formats.relative.php If you would like, feel free to fork the project, and submit a pull request with your modifications. If not I should have some time to look into/fix this issue over the weekend. Thank you for pointing this out. |
Is this fixed? Warning: DateTime::modify() [datetime.modify]: Failed to parse time string (last day of 1 month) at position 9 (o): The timezone could not be found in the database in /home/figure8/domains/billing.figure8.be/external/When.php on line 624 |
Hi Frederik, No, not fixed. I use the modification mentioned in the post, this works with the So clause around line 624 in my version of When.php is this: if($interval == "month")
$this->try_date->format('m'), $this->try_date->format('t')); Does that help? On 11/10/2011 1:41 AM, Frederik Heyninck wrote:
|
It fixes it, thx. |
This works, but it doesn't give accurate dates. Which is whay I turned to "last day of" in the first place Perhaps i'm doing something wrong? |
Pull request for Issue #5 - Exception causing trouble in PHP 5.2.13
With an RRULE such as:
FREQ=MONTHLY;
my production version of PHP (5.2.13) was throwing an exception because of code at around line 630. The message was:
Warning: DateTime::modify() [datetime.modify]: Failed to parse time string (last day of 1 month) at position 9 (o):
The offending line of code was:
$this->try_date->modify('last day of ' . $this->interval . ' ' . $interval);
I believe this version of PHP could not understand 'last day of'.
Now, I'm not sure what the intent of the code was here, but I'm assuming you are wanting to move the date ahead a certain (interval) number of months, landing on the last day of the month. My solution was:
for ($i=0; $i< $this->interval; $i++)
{
$this->try_date->modify('+ 28 days');
$this->try_date->setDate($this->try_date->format('Y'), $this->try_date->format('m'), $this->try_date->format('t'));
}
The +28 days ensure we dont skip a smaller month, and the format('t') gives us the last date of the month in question.
The text was updated successfully, but these errors were encountered: