PHP date parsing -


i have custom moodle plugin else wrote. user enters date in plugin , date gets recorded against learning activity.

originally had problem plugin mistake dates , confused between au(uk) date format , date format. fixed problem using solution here (how make strtotime parse dates in australian (i.e. uk) format: dd/mm/yyyy?).

but weird error pops every , dates (notably july 2nd, 2015) gets it's year , day transposed. 02-07-2015 gets recorded 15-07-2002.

it doesn't appear au vrs date thing because should flip day , month, not year. also, happens specific date. 01-07-2015 , 03-07-2015 work fine.

what's more frustrating can't reproduce on our staging server. problem occurs in our production server, though both running same code , same version of moodle.

what can share of code how processing date, is...

$date[$i] = strtotime(str_replace('/', '-', $date[$i])); 

this has got me wondering if there php setting causing this. or else i'm on looking?

fyi, production server maintained paid hosting provider , don't have access php.ini file (but on staging).

has has issues this? or can suggest start looking find problem?

try adjust format in date function below, in place of using str_replace

if $dat = '2015-07-17'; $date= date('d-m-y', strtotime($dat)); 

or

$date= date('d:m:y', strtotime($dat)); 

or

$date= date('d/m/y', strtotime($dat)); 

or

$date= date('m-d-y', strtotime($dat)); 

Comments