briannesbitt / Carbon

A simple PHP API extension for DateTime.
https://carbon.nesbot.com/
MIT License
16.53k stars 1.28k forks source link

Carbon date is empty in sql statement #955

Closed DaveSanchez closed 7 years ago

DaveSanchez commented 7 years ago

Hi, I'm trying to use Carbon to manage registration users but date is empty when I run sql statement, this is the carbon date:

$now = Carbon::now('America/Monterrey');

So in my PHP function looks like this:

`public function register($code, $fullname, $address, $phones, $email, $register_date){ echo $register_date; //this will output 2017-05-20 22:16:02

  $this->_app['medoo']->debug()->insert('customers',[
        'cus_code' => $code,
        'cus_fullname' => $fullname,
        'cus_address' => $address,
        'cus_phone_s' => $phones,
        'cus_email' => $email,
        'created_at' => $register_date
    ]);
   //as you can see i'm debuging sql statement to see what's about to insert BUT it will output
  //INSERT INTO "customers" ("cus_code", "cus_fullname", "cus_address", "cus_phone_s", "cus_email", "created_at") VALUES ('kokoko', 'kokokok', 'kokokokokoko', 'okokokokoko', 'kokok@k.com')

   die(); 

    return $registration;

}`

so when it's time to insert, date is empty, does anyone know why?

DaveSanchez commented 7 years ago

Solved!!! I just formatted it like this:

Carbon::now('America/Monterrey')->format('Y-m-d H:m:s');