Is there a way to add the current date to a JSON received in php?


I have an andriod app sending data in JSON to a php script and appending it to a mysql table, is there any way to insert the current date without adding it to the app. I am trying to get php to add the current date to BoughtDate inside the same query.

error_reporting(E_ALL); ini_set('display_errors',1);

$dbSuccess = false;
        $dbConnected = mysql_connect($db['hostname'],$db['username'],$db['password']);

        if ($dbConnected) {
            $dbSelected = mysql_select_db($db['database'],$dbConnected);
            if ($dbSelected) {
                $dbSuccess = true;

$data_back = json_decode(file_get_contents('php://input'));

$userName = $data_back->{"User"};
$password = $data_back->{"Pword"};
$BoughtFrom = $data_back->{"Bfrom"};
$VIN = $data_back->{"VIN"};
$Color = $data_back->{"Color"};
$MakeIndex = $data_back->{"Make"};
$ModelIndex= $data_back->{"Model"};
$Year = $data_back->{"Year"};
$Bid = $data_back->{"Bid"};
$INV = $data_back->{"PurchasePrice"};
$BidContact = $data_back->{"Contact"};
$BidEmail= $data_back->{"Email"};

mysql_query("Insert Into tblinventory (VIN, MakeIndex, ModelIndex, Year, Color, Bid, INV,
BidContact, BidEmail, BoughtFrom, BoughtDate)
VALUES ('$VIN','$MakeIndex', '$ModelIndex', '$Year', '$Color', '$Bid',
'$INV', '$BidContact', '$BidEmail', '$BoughtFrom', '$BoughtDate'") or die (mysql_error());

$responses = array();
    $responses[] = array( $VIN . " " . $MakeIndex . " " . $ModelIndex." ". $Year." " );

header("Content-type: application/json");

echo json_encode($responses);

As first the var $BoughtDate is not existent in your current code.

You can fill $BoughtDate by using php function time wich returns the current unix timestamp.

See for further explanation.

Code Snipped: