Closed hirbod closed 8 years ago
This caused the problem:
(new \Moment\Moment($message['createdate'], 'Europe/Berlin'))->subtractMonths(1)->format('d. F');
Looks like subtractMonths don't work when in Janurary. But also a short remember why I have to use it like this: #50
After I've remove subtractMonths(1) the fatal error is gone, but my string is converted into 03. Februar again, instead of 03. Januar. As you could never fix this problem, could you have a look why subtractMonths is not working right now?
Edit: I also tried
$messages[$key]['date'] = date("d. F", strtotime($message['createdate']));
and this works correctly. There is a bug inside of your code.
Hey there. Whats inside of $message['createdate']
?
2016-01-03 16:17:07
Hirbod, I added a test for your issue but all comes out fine on my end as well as on travis' end. I am not having much time at the moment so that I can dig deeper but I am afraid something is off with your environment.
Have a look at the simple test: https://github.com/fightbulc/moment.php/blob/master/tests/unit/Moment/MomentGermanLocaleTest.php#L84
Did you try running this on another setup?
I'm on Debian with PHP 5.4.45. Just tested on my test system (also Debian) with 5.5.31 - same problem. Maybe there is some Debian-Patched problem. No suhosin. I use XCache as cache for 5.4.45 - maybe this cause some problems. PHP 5.5 has APC as Caching-system by default. Which version did you test?
Yo. Follow the link to see which versions I am testing against: https://travis-ci.org/fightbulc/moment.php
I'd love to figure out the issue but I simply cannot make any time to try to setup your system. So the closest I can try to replicate is travis and my work environments which includes also different systems with some of my clients.
It's interesting that running the equivalent of (new DateTime('2016-01-03 16:17:07', 'Europe/Berlin'))->modify('-1 month')
would return a DateTime object with a month number of 13... Because that's the only situation that would cause this specific error to be raised, based on what I see in the code... What situations could cause that?
Hey there.
Running the following code either on my Mac or a Gentoo-Server
returns the correct result of 2015-12-03T16:17:07+01:00
$d = (new Moment\Moment('2016-01-03 16:17:07', 'Europe/Berlin'))->modify('-1 month');
$d->format('c'); // 2015-12-03T16:17:07+01:00
I am running php56
on both machines.
So I guess Debian / Gentoois the problem. Debian ships own patched PHP Versions, I guess somewhere there is the problem. Any chance to test on Debian ?
Hi @fightbulc
I did nothing - it just looks like moment.php does not like January.