Strtotime() doesn't work with dd/mm/YYYY format

前端 未结 15 1427
Happy的楠姐
Happy的楠姐 2020-11-22 09:33

I really like the strtotime() function, but the user manual doesn\'t give a complete description of the supported date formats. strtotime(\'dd/mm/YYYY\')<

15条回答
  •  半阙折子戏
    2020-11-22 09:49

    I tried to convert ddmmyy format to date("Y-m-d" format but was not working when I directly pass ddmmyy =date('dmy')

    then realized it has to be in yyyy-mm-dd format so. used substring to organize

    $strParam = '20'.substr($_GET['date'], 4, 2).'-'.substr($_GET['date'], 2, 2).'-'.substr($_GET['date'], 0, 2);  
    

    then passed to date("Y-m-d",strtotime($strParam));

    it worked!

提交回复
热议问题