nnesterov
nnesterov

Reputation: 1322

Telegram Bot. Get User timezone

When developing bot for Telegram is there any way to get user timezone? Date field in Message object contains UNIX timestamp only. I want to create bot sending some messages an fixed time of day to subscribed user. User can have different time zones and I don't want to force users to explicit send their timezone to bot in message.

Upvotes: 36

Views: 15578

Answers (3)

esolCrusador
esolCrusador

Reputation: 51

You can also create link button which opens temprorary browser window.

Where you request timezone from browser encodeURIComponent(Intl.DateTimeFormat().resolvedOptions().timeZone) browser's timezone and redirect back with timezone in query string and store it.

And than this window can be automatically closed by redirecting to your bot https://t.me/{your_bot_name}

Upvotes: 4

budiDino
budiDino

Reputation: 13527

I've added /set_utc_offset command to my bot where users enter the time difference in minutes compared to UTC

Upvotes: 5

Danil Pyatnitsev
Danil Pyatnitsev

Reputation: 2292

It's imposible by standard Bot API.

You can ask user for location, and next, from this location calculate timezone for user.

Upvotes: 32

Related Questions