Hello Matteo,
> How did you do it?
I played with the time_zone variable in MySQL.
I would like to find a way to accurately convert the timestamps to MySQL date on DB side.
I found the FROM_UNIXTIME function unreliable. It's as if moodle would calculate DST into the persisted timestamp.
Another test I did:
- Created a custom date/time profile field with the Include time? option checked.
- Went to my profile settings and filled up the new field with this datetime: 24 March 2018, 2:00 PM
- The value in the DB: 1524661200 which checks out.
- Changed to field again to 25 April 2018, 2:00 PM (the day when DST kicked in)
- The value in the DB: 1521982800 which is now one hour behind!
FROM_UNIXTIME expects the timestamp to be in UTC/GMT.
I found this code.
When setting a date/time profile field, the value of $applydst is true.
(Altough if the condition check is removed, then it overcorrects the timestamp by applying the difference two times. Saving a date/time profile field calls this function three times actually.)