# Timezone question

**URL:** <https://swi-prolog.discourse.group/t/timezone-question/2101>\
**Category:** General\
**Created:** [April 3, 2020, 9:46pm UTC](https://swi-prolog.discourse.group/t/timezone-question/2101 "2020-04-03T21:46:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![esad](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/esad/32/884_2.png) [@esad](https://swi-prolog.discourse.group/u/esad)\
**Post date:** [April 3, 2020, 9:46pm UTC](https://swi-prolog.discourse.group/t/timezone-question/2101/1 "2020-04-03T21:46:16Z")

</div>

I am trying to use `date_time_stamp/2` to get a timestamp for a specific time in specific time zone. My local timezone is CEST, when I try to construct a timestamp in another timezone (let’s say EST) I get:

```
?- date_time_stamp(date(2020,2,10,2,55,0, Offset, 'EST', D), T).
Offset = -3600, % This is CEST offset
D = false,
T = 1581299700.0.

```

It seems ‘EST’ was ignored. However, when I do:

```
?- setenv('TZ', 'EST'), date_time_stamp(date(2020,2,10,2,55,0, Offset, 'EST', D), T).
Offset = 18000,
D = false,
T = 1581321300.0.

```

It works. It seems that `date_time_stamp/2` ignores Timezone (it will unify with any atom), which is strange because that should be used to determine if daylight saving was true or false. Is this a bug or intended behaviour? I’m using swipl v8.1.21.

---

<div class="post-metadata">

**Author:** ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)\
**Post date:** [April 4, 2020, 7:38am UTC](https://swi-prolog.discourse.group/t/timezone-question/2101/2 "2020-04-04T07:38:53Z")

</div>

The time functions use the standard C runtime functions for dealing with time zones. As this is controlled from the process-wide `TZ`, it can only safely reason about one time zone (the current/local one) and UTC for which we do not need all this complexity.

I’m actually quite surprised that setting the environment variable does allow you to change the time zone on the fly. I doubt this is portable. You probably need something else if you want to reason about time on various places in the world in the same process.
