1

I'm trying to save a date of birth field in the create user view of my app, I'm using bootstrap datepicker to make it more friendly. have it formatted to yyyy-mm-dd to match the sql date format.

in the create view, when i pick the date it looks like this: 1993-07-06

but when I save and go to the database to check the newly created user I always get this on the birthday field:

2180-01-05

Does the boostrap datepicker has something to do with it?

i just have this in my js

$('#data_1 .input-group.date').datepicker({
    format: "yyyy-mm-dd",
    todayBtn: "linked",
    keyboardNavigation: false,
    forceParse: false,
    autoclose: true
});

Any help will be much appreciated!

DanielHolguin
  • 305
  • 4
  • 13
  • 2
    **http://stackoverflow.com/questions/33734683/cakephp-3-not-saving-datetime/33741772#33741772** – ndm Apr 01 '16 at 22:40

1 Answers1

-1

birthday field in your database check data type is date after that use save birthday field check date format please see the below example

$date='2016-04-02';
$date1=date('Y-m-d',strtottime($date));
echo $date1;

After that save your data into field you. use cake php

$this->request->data['Modelname']['datefiled']=$date1;
 $this->Modelname->create();
        if ($this->Modelname->save($this->request->data)) {
}
Digpal Singh
  • 166
  • 1
  • 5