jimfog Posted July 3, 2012 Share Posted July 3, 2012 The code you are going to see below was working fine before updating to PHP 5.4.4: $now = new DateTime($newdate);//the code below depicts last and first day of month$fstdmonth=clone $now;$lstdmonth=clone $now;$fstdmonth->modify('first day of month');$lstdmonth->modify('last day of month'); I am trying to get the last and first day of a month.Now here is the error message I get upon running the script: Warning: DateTime::modify(): Failed to parse time string (first day of month) at position 13 (m): The timezone could not be found in the database in C:\Apache24\htdocs\Appointments\Frontend\output_functions.php on line 47 Any ideas why this might happening? Link to comment Share on other sites More sharing options...
boen_robot Posted July 3, 2012 Share Posted July 3, 2012 The key is The timezone could not be found Open up php.ini, find "date.timezone"and set that line to date.timezone = Europe/Athens Link to comment Share on other sites More sharing options...
jimfog Posted July 3, 2012 Author Share Posted July 3, 2012 I have already done that: date.timezone = "Europe/Athens" Before I fixed the above I was getting many errors related to date functions in the script.Now the only errors left are the one mentioned in this topic. Link to comment Share on other sites More sharing options...
justsomeguy Posted July 3, 2012 Share Posted July 3, 2012 You might not have the PHP timezonedb installed or set up correctly. Link to comment Share on other sites More sharing options...
boen_robot Posted July 3, 2012 Share Posted July 3, 2012 Ah. I see. Well, I tried the code, and I think I found it. I missed the part: Failed to parse time string (first day of month) at position 13 (m) What this message says is that the "m" (as in "month") is where interpretation collapsed. The message about the timezone suggests the word "month" was treated as a timezone for some reason.Using "this" clears this out, so: $now = new DateTime($newdate);//the code below depicts last and first day of month$fstdmonth=clone $now;$lstdmonth=clone $now;$fstdmonth->modify('first day of this month');$lstdmonth->modify('last day of this month'); Link to comment Share on other sites More sharing options...
jimfog Posted July 4, 2012 Author Share Posted July 4, 2012 Yes boen robot, that worked, thanks very much. Second, the code worked with a previous version of PHP I had. I wonder if the reason it does not work with PHP 5.4.4(the one I just update to) it is because maybe there were changes in the relative time formats syntax Link to comment Share on other sites More sharing options...
boen_robot Posted July 4, 2012 Share Posted July 4, 2012 Maybe. But I don't remember "this" ever being an optional part of the relative time syntax, so this is probably more of a bug fix. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.