Php data Insert error

Asked

Viewed 20 times

0

I’m trying to insert date into a php record, only it’s presenting an error, which I imagine is quite simple, but it’s taking me a precious little time.

I’ve tried to put date('Y-m-d H:i:s', strtotime($this->data_fundacao)) where I send the parameter. In the two attempts, in one, he registered 1969-12-31 21:00:00 and in another he registered 2069-12-31 00:00:00

In my tests I saw that it picks the date right, only it does not insert.

<div class="input-group has-feedback" id="divDataFundacao">
     <div class="input-group-addon">
           <i class="fa fa-calendar"></i>
     </div>
     <input type="text" class="form-control input-group" name="txtDataFundacao" placeholder="Ex.: 03/03/1995" id="txtDataFundacao" autocomplete="off" maxlength="10" onkeypress="return BloqueiaLetras(event)"                                               onkeyup="mascara(this, mdata);">
</div>

PHP

//pega os dados no form
$dataFundacao = $_POST['txtDataFundacao'];

//envia a classe de insert
$Partner->setDataFundacao($dataFundacao);

//na classe
    private $data_fundacao;


 public function setDataFundacao($data_fundacao){
        return $this->data_fundacao = $data_fundacao;
    }

   $stmt->bindParam(":data_fundacao",date('Y-m-d H:i:s', strtotime($this->data_fundacao)),PDO::PARAM_STR);
  • What format comes in $this->data_fundacao?

  • Data Brazilian format. When I send it to the bank, I send it in mysql format

  • 1

    Thanks for the idea @Marcelodeandrade, make the conversion before sending worked

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.