PHP date showing '1970-01-01 ' after conversion

前端 未结 8 596
醉话见心
醉话见心 2020-12-04 16:44

I have a form in which date format is dd/mm/yyyy . For searching database , I hanverted the date format to yyyy-mm-dd . But when I echo

8条回答
  •  萌比男神i
    2020-12-04 17:19

    $date1 = $_REQUEST['date'];
    
    if($date1) {
        $date1 = date( 'Y-m-d', strtotime($date1));
    } else {
        $date1 = '';
    }
    

    This will display properly when there is a valid date() in $date and display nothing if not.
    Solved the issue for me.

提交回复
热议问题