katemihalikova / ion-datetime-picker

Date and/or time picker for awesome Ionic framework
MIT License
168 stars 101 forks source link

Getting 2 hours less than I want #24

Closed juanwilde closed 8 years ago

juanwilde commented 8 years ago

Hi. I'm trying to set a value for hours but when I send that info to my API I always store 2 hours less than I want.

This is the piece of code: `

Fecha de salida {{new.date_trip| date: 'd MMM y @ HH:mm' : 'UTC + 2'}} (click aquí para selecionar)
            </ion-list>`

In the Ionic App it sees ok, but the in the Database is not stored as I want.

Thanks in advance

katemihalikova commented 8 years ago

Hi Juan, it seems that you are not correctly storing/reading the timezone from your time. Please check what is being sent to server and what is being stored in database to discover if the problem is in your ionic code or on server.

juanwilde commented 8 years ago

Thanks for your answer. I checked the server and it's ok. I mean that if I want to store a new datetime from the web app it is stored ok, but when I try it from the ionic app it fails... This is the datetime what I send from ionic: date_trip:Thu Apr 28 2016 15:40:00 GMT+0200 (CEST) And this is what I get into the server when I insert it into the server if (isset($data['date_trip'])) $trip->setDateTrip(new \DateTime($data['date_trip'])); [date_trip] => 2016-04-28T13:40:00.000Z

The server timezone is Europe/Madrid

Thanks again for your time :)

katemihalikova commented 8 years ago

2016-04-28T13:40:00.000Z is the same datetime as Thu Apr 28 2016 15:40:00 GMT+0200 (CEST) so I see no problem. Could you please provide more info?

juanwilde commented 8 years ago

Well, I think my problem is about datetime conversion between Ionic and PHP Server, because when I do the insert from the web (working with symfony) if I set 16:00 stores 16:00 not 14:00

katemihalikova commented 8 years ago

This is definitely problem on your server, either in API for ionic app or in settings of your Web server. You can use the snippet from #15 to convert the time in ionic app to timezone-less. This fix should help you, but does not fix the bug you have on server side.