silverbullet icon indicating copy to clipboard operation
silverbullet copied to clipboard

Timezone ignored on Docker container

Open rc2dev opened this issue 5 months ago • 4 comments

First of all, thanks for Silverbullet!

I have a command to create a note with name "{{ today }} {{ time }}". However, time is UTC instead of local.

My compose.yaml:

services:
  silverbullet:
    image: zefhemel/silverbullet
    container_name: silverbullet
    restart: unless-stopped
    environment:
      - SB_USER=${USERNAME}:${PASSWORD}
      - PGID=1000
      - PUID=1000
      - TZ=America/Sao_Paulo
    volumes:
      - /mnt/dietpi_userdata/silverbullet:/space
    networks:
      - proxy-net

networks:
  proxy-net:
    external: true

Running date inside the container returns UTC time.

I've also tried, with no luck:

   volumes:
      - "/etc/localtime:/etc/localtime:ro"
      - "/etc/timezone:/etc/timezone:ro"

rc2dev avatar Feb 04 '24 17:02 rc2dev

More info: {{ today }} seems to respect timezone fine, while {{ time }} doesn't.

rc2dev avatar Feb 09 '24 16:02 rc2dev

I encountered the same problem

daydaya avatar Mar 02 '24 17:03 daydaya

I don't think this is a docker issue, it's indeed a UTC issue. The current time function gives you UTC time, you can define a space function that gives you the local time. Try this:

Somewhere in your space:

```space-script
silverbullet.registerFunction({name: "localTime"}, () => Temporal.Now.plainTimeISO().toString().split('.')[0])
```
Then call it somewhere:
```template
{{localTime}}
```

zefhemel avatar Mar 02 '24 18:03 zefhemel

I don't think this is a docker issue, it's indeed a UTC issue. The current time function gives you UTC time, you can define a space function that gives you the local time. Try this:

Somewhere in your space:

```space-script
silverbullet.registerFunction({name: "localTime"}, () => Temporal.Now.plainTimeISO().toString().split('.')[0])

Then call it somewhere:

{{localTime}}

This is useful for me, thank you very much

daydaya avatar Mar 03 '24 14:03 daydaya