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

前端 未结 8 573
醉话见心
醉话见心 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条回答
  • 2020-12-04 17:34

    Replace / with -:

    $date1 = strtr($_REQUEST['date'], '/', '-');
    echo date('Y-m-d', strtotime($date1));
    
    0 讨论(0)
  • 2020-12-04 17:35

    Use below code for php 5.3+:

    $date = new DateTime('1900-02-15');
    echo $date->format('Y-m-d');
    

    Use below code for php 5.2:

    $date = new DateTime('1900-02-15');
    echo $date->format('Y-m-d');
    
    0 讨论(0)
提交回复
热议问题