In an Symfony/Angular project, i use a datepicker (Bootstrap datepicker) to select a date. This gives me an object value i then want to send to php to be persisted.
The problem is there is an time offset giving me the wrong value in the database.
I'm in a french setup, i've defined in php.ini the correct timezone.
- In the datepicker, i choose :
17/11/2016
which is translated inThu Nov 17 2016 00:00:00 GMT+0100 (CET)
- but when i send to php with ajax call : i have
2016-11-16T23:00:00.000Z
php side - then in my Db with doctrine, the datetime field contains :
2016-11-16 23:00:00
- When i want to display back the saved values, it naturally gives in the datepicker :
16/11/2016
which is in fact if i do a console.log() :{"date":"2016-11-16 23:00:00.000000","timezone_type":3,"timezone":"Europe/Paris"}
I don't use any conversion in the process. I did try to "cast" the js : start.toUTCString()
, i also tried to set afterward the time to 0 in php : $start.setTime(0, 0, 0);
without success.
So, how can i save and display the correct date ?