Select date from my db without seconds using PHP MySql

后端 未结 6 1924
生来不讨喜
生来不讨喜 2020-12-20 06:25

Well, I save the date\'s with minutes and second in my database.

And I want to check if the date from my db = to date today.

I read about this,

6条回答
  •  轮回少年
    2020-12-20 06:42

    Here you go:

    $dbdate = '8/21/2015 11:16:12 AM'; //add your database date here
    $dt = new DateTime($dbdate);
    $date = $dt->format('Y-m-d');
    $today = date("Y-m-d"); //get current date
    
    
    //now compare your dates
    if($date == $today)
    {
    }
    

提交回复
热议问题