Feature #599
Manage timezones
Start date:
11/02/2010
Due date:
19/02/2010
% Done:
100%
Estimated time:
6.00 h
Complexity:
Normal
SCRUM pts - complexity:
20
Description
Manage timezones at the platform level (settings_current) and at user level (user_extra_field)
Create a function api_get_local_time($time,$format,$user_id=null) which returns a given UTC time into a localized time and format.
/** * Returns the local time for the current user */ function api_get_local_time($time,$format,$user_id=null) { global $_user; ... }
Related issues
History
Updated by Yannick Warnier over 12 years ago
- Due date set to 19/02/2010
- Status changed from New to Assigned
- Assignee set to Anonymous
Updated by Anonymous over 12 years ago
- Put the timezone in the ''settings_current'' table (let the admin chose the timezone during the installation or determine it automatically from the server ?) during portal installation
- Which table should I use for the timezone at the user level ? user ?
- Add a timezone field in the user profile
- Create the function in the file lib/main_api.lib.php
Updated by Anonymous over 12 years ago
The best way of handling dates and times in PHP and MySQL is to store dates and times as DATETIME types in MySQL in UTC (Universal Time). Currently, chamilo has both DATETIME and TIMESTAMP types in its database and, in the future, everything should be converted to DATETIME, and a PHP function should be used to convert any date and time to UTC before storing it in the DB.
I propose two functions:
/** * Returns the given date as a DATETIME in UTC format. This function has to be used before entering any date in the DB. * @param mixed The datetime to be converted (can be a string, a timestamp etc...) * @return string The datetime in UTC to be inserted in mysql */ function api_get_utc_datetime($datetime) { ... }
/** * Returns the local time in a format given as an argument * @param string The time to be converted * @param string The format to be used. The default format is DATETIME * @param string The timezone to be converted from. If null, UTC will be assumed * @param string The timezone to be converted to. If null, the timezone will be determined based on user preference, or timezone chosen by the admin for the platform. * @return string The converted time */ function api_get_local_time($time, $format=null, $from_timezone=null, $to_timezone=null) { ... }
Updated by Anonymous over 12 years ago
Requirements for the admin:
- Must be able to configure the default timezone of the platform * Must be able to allow/disallow users to change their timezone
Requirements for the users:
- If the admin allowed it, users must be able to change their timezone