#6189·wails

Android: time.Local does not reflect the device timezone

Author: sinspiredCreated Sep 28, 2026Updated Sep 28, 2026
LabelsBugv3

Wails version family

v3

Exact Wails version

v3.0.0-beta.26

Operating System

Android (experimental)

Description

On Android, time.Local appears to remain incorrect in some Wails applications, even when the device timezone is configured properly.

I recently encountered this while testing a Wails v3 Android application. Dates and times were behaving as if the application was running in UTC rather than the device's configured timezone (for example Asia/Shanghai).

As a workaround, I manually read Android's timezone property and override time.Local during startup:

go
//go:build android

package main

/*
#include <sys/system_properties.h>
#include <stdlib.h>
*/
import "C"

import (
	"time"
	"unsafe"
)

func initAndroidTimeZone() {
	cname := C.CString("persist.sys.timezone")
	defer C.free(unsafe.Pointer(cname))

	var buf [128]C.char

	n := C.__system_property_get(cname, &buf[0])
	if n <= 0 {
		return
	}

	tz := C.GoStringN(&buf[0], C.int(n))

	loc, err := time.LoadLocation(tz)
	if err != nil {
		return
	}

	time.Local = loc
}

After applying this workaround, time handling became consistent with the Android system timezone.

This feels like something that should ideally be handled by the runtime rather than requiring every application to implement its own Android-specific fix.

One possible improvement would be to expose the device timezone through the existing mobile bridge, similar to how APIs such as application.Mobile.SafeAreaJSON() are currently exposed.

For example:

go
application.Mobile.Timezone()

which could internally use:

java
TimeZone.getDefault().getID()

and return values such as:

Asia/Shanghai
Europe/London
America/New_York

This would allow applications to correctly initialize time.Local without relying on Android system properties or custom CGO code.

I'm not sure whether this is a Wails runtime issue, a Go mobile/runtime behavior issue, or expected Android behavior, but I wanted to share the workaround and start a discussion. If this is a known limitation, perhaps exposing timezone information through the mobile bridge would be a useful addition.

To Reproduce

  1. Create a new Wails v3 application targeting Android.

  2. Log the following values during startup:

go
fmt.Println(time.Now())
fmt.Println(time.Now().Location())
fmt.Println(time.Local)
  1. Build and run the application on an Android device configured with a non-UTC timezone (for example, Asia/Shanghai).

  2. Observe that Go's local timezone may not match the device timezone.

  3. Apply the workaround shown in this issue and observe that time handling becomes consistent with the Android system timezone.

Expected behaviour

The application's local timezone should automatically match the Android device timezone.

For example, if the device timezone is set to Asia/Shanghai, then:

go
time.Now().Location()

### Screenshots

_No response_

### Attempted Fixes

_No response_

### System Details

```shell
Wails v3.0.0-beta.26 › Wails Doctor

# System

┌──────────────────────────────────────────────────────────────────────┐
| Name              | Windows 10 Pro                                   |
| Version           | 2009 (Build: 26200)                              |
| ID                | 25H2                                             |
| Branding          | Windows 11 专业版                                |
| Platform          | windows                                          |
| Architecture      | amd64                                            |
| Go WebView2Loader | true                                             |
| WebView2 Version  | 153.0.4234.48                                    |
| CPU               | 11th Gen Intel(R) Core(TM) i5-1135G7 @ 2.40GHz   |
| GPU               | Intel(R) Iris(R) Xe Graphics (Intel Corporation) |
| Memory            | 16GB                                             |
└──────────────────────────────────────────────────────────────────────┘

# Build Environment

┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
| Wails CLI      | v3.0.0-beta.26                                                                                      |
| Go Version     | go1.27.1                                                                                            |
| -buildmode     | exe                                                                                                 |
| -compiler      | gc                                                                                                  |
| CGO_ENABLED    | 0                                                                                                   |
| DefaultGODEBUG | cryptocustomrand=1,tlssecpmlkem=0,tracebacklabels=0,urlstrictcolons=0,x509sslcertoverrideplatform=0 |
| GOAMD64        | v1                                                                                                  |
| GOARCH         | amd64                                                                                               |
| GOOS           | windows                                                                                             |
└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

Additional context

  • Verified that the Android device timezone was correctly configured.

  • Tested Go's standard timezone handling (time.Local, time.Now().Location()) and found that the reported timezone did not match the device timezone.

  • Searched for existing Wails Android timezone-related issues but could not find a documented solution.

  • Implemented a workaround by reading Android's persist.sys.timezone system property via CGO and explicitly setting time.Local, which resolved the issue in my application.

go
loc, err := time.LoadLocation(tz)
if err == nil {
    time.Local = loc
}
  • Investigated exposing timezone information through the Android bridge (similar to application.Mobile.SafeAreaJSON()), but this currently does not appear to be available as a built-in mobile API.