Hello everyone,
Everytime I save a date/time field into my MySQL database, it’s saved in UTC timezone. I’ve already checked MySQL settings and it’s fine. Server settings also are in the same timezone.
Dou you guys have an idea where do I have to change in Dreamfactory configurations to set my local timezone?
Thanks in advance.
Fernando
1 Like
Hey @flpozzato,
Have you tried this PHP in which you add a specific timezone? The regional settings are in 'php.ini'.
Then edit/etc/php.ini
to set the time zone manually (otherwise DreamFactory will bomb with a php error message that isn’t its fault)
date.timezone= America/New_York
;Defines the default timezone used by the date functions
;http://php.net/date.timezone
date.timezone = "Europe/Paris"
You should also be able to set regional settings in your app with the ` ini_set function.`
Also[ here under Schema:](https://wiki.dreamfactory.com/DreamFactory/Features/Database/Schema)
timestamp: a date and time stamp with timezone awareness where applicable, i.e. MySQL’s timestamp not null default 0 or MSSQL’s datetimeoffset.
[For PostgreSQL:](https://wiki.dreamfactory.com/DreamFactory/Features/Database/PostgreSQL)
timezone - String. Optional. Set the timezone for this connection.
[ For MySQL:](https://wiki.dreamfactory.com/DreamFactory/Features/Database/MySQL)
timezone - String. Optional. Set the timezone for this connection.
Thanks,
@AlexBowen
Thanks Alex. I’ll try those to see what happens.
1 Like
Yes, do let me know how it works for you @flpozzato.
Thanks,
@AlexBowen
Hi Alex… just came back to this again today. Checked everything and all looks fine. Server has the correct timezone, php-fpm and db also in the same timezone. I really don’t find where to modify this date. It seems to be the webserver (nginx), since the http request headers have UTC dates.
Any thoughts?
Hey @flpozzato,
You can set the timezone of the database in the service config. In the config screen for the service, there’s a setting called Timezone.
Perhaps try that and let us know how it works.
Thanks,
@AlexBowen
Hi Alex,
Just tried that and it’s not working as well. Just forgot to mention, but I’m using angular and angular locale services. I’ll try to understand if could be something related to that and let you know.
Thanks,
Fernando
1 Like
Hey @flpozzato,
I’m not familiar with Angular, so I can’t really help you there.
How are you inserting the date? I assume you are autogenerating it, but at what point in the transaction? Are you doing it in your code, in DreamFactory, perhaps default expression in the database?
Thanks,
@AlexBowen
Hi Alex,
The user needs to select an date/time that fills an object with the selected date. Then I use it to post this object to DreamFactory using Angular ngResource. When debugging it in Developer Tools, this date is using the correct timezone in the request.
When I check the request record in the database after posting it, date is then saved in UTC. This table has also a ‘creation_date’ field defaulted to NOW(). Since I don’t pass this information in the request, this date is saved in the proper timezone, not UTC.
Thanks,
Fernando
1 Like