how to insert the constant date in mysql using php

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • varun aggarwal
    New Member
    • Feb 2007
    • 26

    how to insert the constant date in mysql using php

    Hi
    i am inserting the date in the mysql table using the php.
    I dont know but its not working, i know that the error is because of this only.
    I am getting the date input from the user(for example in sending card to someone the user enters the date, when the card should be sent).
    I have to enter this constant date in the mysql datbase where the column type is "date".
    Any help would be appreciated.
    Thanks
  • pbmods
    Recognized Expert Expert
    • Apr 2007
    • 5821

    #2
    Heya, Varun.

    Try using strtotime() and date() to standardize your input:

    [CODE=php]
    $date = $_POST['date']; // User-submitted date string.
    $date = date('Y-m-d', strtotime($date )); // Convert to standard format.
    .
    .
    .
    $sql = "REPLACE INTO `tableName` (`date`) VALUES('{$date} ')";
    [/CODE]

    Comment

    Working...