Select date from my db without seconds using PHP MySql

后端 未结 6 1930
生来不讨喜
生来不讨喜 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 07:01

    Its not answer, I have a small problem..

    I tried it:

    $dbdate = "21/08/2015 10:13";
    

    .

       $select_last_vote = mysql_query("SELECT `Date` FROM `Vote` WHERE `IP` = '$ip' AND `VoteID` = '$VoteID' order by `Date` DESC LIMIT 1;");
                $select_last_vote = mysql_fetch_array($select_last_vote);
                $dbdate = $select_last_vote["Date"];
                $takeResult = mysql_query("SELECT DATE_FORMAT(STR_TO_DATE('$dbdate', '%d/%m/%Y' ), '%d/%m/%Y') as Date ;");
                $Result_date = mysql_fetch_array($takeResult);
                $result_date = $Result_date["Date"];
                $today = date("d/m/Y");
        if($result_date == $today)
            {
            echo "this is today $result_date, $today";
            }
            else { // there is my output: You can vote! 00/00/0000
            echo "You can vote! $result_date";
            }
    

    Its working now (:

    Thanks for all!!

提交回复
热议问题