I have a custom Moodle plugin that somebody else wrote. A user enters a date in the plugin and that date gets recorded against a learning activity.
Originally I had a problem where the plugin would mistake some dates and get confused between AU(UK) date format and US date format. I fixed that problem using the solution from here (How to make strtotime parse dates in Australian (i.e. UK) format: dd/mm/yyyy?).
But now a weird error pops up every now and then where certain dates (notably July 2nd, 2015) gets it's year and day transposed. So 02-07-2015
gets recorded as 15-07-2002
.
It doesn't appear to be an AU vrs US date thing because that should just flip the day and month, not the year. Also, it only happens with that specific date. 01-07-2015
and 03-07-2015
work fine.
What's even more frustrating is that I can't reproduce this on our staging server. The problem only occurs in our production server, even though they are both running the same code and same version of Moodle.
What I can share of the code is how I am processing the date, which is...
$date[$i] = strtotime(str_replace('/', '-', $date[$i]));
This has got me wondering if there could be some PHP setting that could be causing this. Or something else I'm over looking?
FYI, the production server is maintained by a paid hosting provider and I don't have access to the php.ini file (but I do on staging).
Has anyone has issues like this? Or can you suggest where I could start looking to find the problem?