Results 1 to 2 of 2

Thread: fetch current date record of dd/mm/yyyy format in php mysql

Hybrid View

  1. #1
    Join Date
    Jan 2014

    Question fetch current date record of dd/mm/yyyy format in php mysql

    Hello experts,

    I am stuck with an query. Actually i want to fetch current date records from my database and the below code probably fetches all my current date records. But it fetches in d/m/y (26/01/14) format but i need in dd/mm/yyyy (26/01/2014) .
    Below is the code which gives output as d/m/y format:

    PHP Code:
    // Check connection
    if (mysqli_connect_errno())
    "Failed to connect to MySQL: " mysqli_connect_error();
    $today date('d-m-y');
    $result mysqli_query($con,"SELECT * FROM Persons WHERE DATE(startdate) = '$today'");

    "<table border='1'>


    $row mysqli_fetch_array($result))
    "<td>" $row['id'] . "</td>";
    "<td>" $row['name'] . "</td>";
    "<td>" $row['startdate'] . "</td>";
    "<td>" $row['details'] . "</td>";

    I tried with the above code and also tried to change the date format i.e :
    $today = date('d-m-y');
    to $today = date('dd-mm-yyyy');

    I am not understanding what i am missing. Just need some help in this. Any help is appreciated.

  2. #2
    Join Date
    Jul 2013
    Voorheesville NY USA
    Have you tried displaying the result of your DATE function from your query statement to see what that value looks like? AFAIK, dates from a MySQL db are in the form yyyy-mm-dd which you can alter by using the DATE_FORMAT (?) function, not DATE. I think in your case you can alter either the query's function or the date functions format to make them align

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center

Recent Articles