How to get user locale and timezone

I want to get Users locale and timezone, but these two codes return nothing

 private function getUserTimezone($user) {
    $uid = $user -> getUID();
	  $config = \OC::$server -> getConfig();
	  $timezone = $config -> getUserValue($uid, 'core', 'timezone');
	  return $timezone;

  private function getUserLocale($user) {
    $uid = $user->getUID();
    $config = \OC::$server->getConfig();
    $locale = $config->getUserValue($uid, 'core', 'locale');
    return $locale;

i want their information based on their dashboard

Hi ydo,

this is the way we get the timezone in Forms:

1 Like