# Date format is wrong

**URL:** <https://discuss.tryton.org/t/date-format-is-wrong/4172>\
**Category:** User\
**Created:** [May 9, 2021, 4:51pm UTC](https://discuss.tryton.org/t/date-format-is-wrong/4172 "2021-05-09T16:51:35Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![pocock](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/p/a88e57/32.png) [@pocock](https://discuss.tryton.org/u/pocock)\
**Post date:** [May 9, 2021, 4:51pm UTC](https://discuss.tryton.org/t/date-format-is-wrong/4172/1 "2021-05-09T16:51:35Z")

</div>

I’m using the Debian package of Tryton v5.0.5-1

My system has a European locale

```auto
LANG=en_IE.UTF-8
LC_TIME=en_IE

```

In the user interface, the dates appear in the US format, e.g. `05/31/2021` while I would expect to see the day before the month, e.g. `31/05/2021`

---

<div class="post-metadata">

**Author:** ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)\
**Post date:** [May 9, 2021, 5:24pm UTC](https://discuss.tryton.org/t/date-format-is-wrong/4172/2 "2021-05-09T17:24:20Z")

</div>

The client uses the date format defined on the language of `trytond`.

---

<div class="post-metadata">

**Author:** ![dave](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/d/ee7513/32.png) [@dave](https://discuss.tryton.org/u/dave)\
**Post date:** [May 10, 2021, 11:26am UTC](https://discuss.tryton.org/t/date-format-is-wrong/4172/3 "2021-05-10T11:26:27Z")

</div>

Just to add to this answer, there is an `en` localization that has the date in the US format. This can be changed by going into the `Administration -> Localization -> Languages`.

If Tryton was translated into `en_IE` (which it isn’t at the moment) I’m pretty sure it would use the date format from that Localization rather than the one defined for `en`.

---

<div class="post-metadata">

**Author:** ![pokoli](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/pokoli/32/22_2.png) [@pokoli](https://discuss.tryton.org/u/pokoli)\
**Post date:** [May 10, 2021, 12:20pm UTC](https://discuss.tryton.org/t/date-format-is-wrong/4172/4 "2021-05-10T12:20:31Z")

</div>

Indeed you can just create a new language named “European English” or whatever you want an use the `en_IE` code for it. This will allow to set a diferent value for the “Date” format (and also other formats) while keeping the translations for the en format.

With this setup you can set diferent languages on each party so each one gets it’s correct format.

This is how we manage the Spanish language for Europe and Latin America.

---

<div class="post-metadata">

**Author:** ![pocock](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/p/a88e57/32.png) [@pocock](https://discuss.tryton.org/u/pocock)\
**Post date:** [May 11, 2021, 7:58pm UTC](https://discuss.tryton.org/t/date-format-is-wrong/4172/5 "2021-05-11T19:58:41Z")

</div>

I went into Administration → Localization → Languages → English

I changed the date format to `%d/%m/%Y`

The Invoice document in LibreOffice now shows the date in the d/m/y format

The tryton-client GUI still shows incorrect (US) m/d/y dates

I exited the GUI and opened it again and it is still the same, m/d/y

Is there anything else I need to do to make the GUI show the correct date format?

I’m using the 5.0 packages on Debian buster.

---

<div class="post-metadata">

**Author:** ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)\
**Post date:** [May 11, 2021, 11:00pm UTC](https://discuss.tryton.org/t/date-format-is-wrong/4172/6 "2021-05-11T23:00:28Z")

</div>

> [@pocock](#):
>
> I’m using the 5.0 packages on Debian buster.

Use a recent version before reporting issue.

---

<div class="post-metadata">

**Author:** ![pocock](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/p/a88e57/32.png) [@pocock](https://discuss.tryton.org/u/pocock)\
**Post date:** [July 31, 2021, 5:11pm UTC](https://discuss.tryton.org/t/date-format-is-wrong/4172/7 "2021-07-31T17:11:28Z")

</div>

I downloaded the 6.0.4 tarball, unpacked it and connected to `demo6.0.tryton.org`

I went to Administration, Localization, Languages, English and found it was using `%m/%d/%Y`

I replaced that with `%d/%m/%Y` and clicked Save

Then I went to look at the Fiscal Year start and end dates. The end date is `12/31/2021`.

I logged out of the client and started it again. After logging in again, I look at the Fiscal Year start and end dates. The end date is `31/12/2021`.

On 5.0.4 the invoices printed with LibreOffice have the correct date format. The problem is only in the desktop GUI date fields.

Does anybody know what change in the desktop client between 5.0.4 and 6.0.4 has fixed this issue?

Could the desktop client display a warning when somebody changes a setting that requires a restart like this?

---

<div class="post-metadata">

**Author:** ![pocock](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/p/a88e57/32.png) [@pocock](https://discuss.tryton.org/u/pocock)\
**Post date:** [July 31, 2021, 5:12pm UTC](https://discuss.tryton.org/t/date-format-is-wrong/4172/8 "2021-07-31T17:12:58Z")

</div>

Could anybody clarify the `language =` value in `trytond.conf`?

Is that value selecting one of the entries defined in the table that appears at Administration/Localization/Languages?

Or is that value selecting one of the values from `locale -a`?

Or does it need to be valid in both places?

Or something else?

---

<div class="post-metadata">

**Author:** ![pocock](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/p/a88e57/32.png) [@pocock](https://discuss.tryton.org/u/pocock)\
**Post date:** [July 31, 2021, 5:22pm UTC](https://discuss.tryton.org/t/date-format-is-wrong/4172/9 "2021-07-31T17:22:58Z")

</div>

I tried a few other versions:

Tryton client 6.0.0: the date appears correctly

Tryton client 5.8.12: the date is always m/d/Y, even after a restart

Therefore, it looks like the bug was fixed between 5.8.12 and 6.0.0. Does anybody know the reason it works now?

---

<div class="post-metadata">

**Author:** ![pocock](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/p/a88e57/32.png) [@pocock](https://discuss.tryton.org/u/pocock)\
**Post date:** [July 31, 2021, 6:17pm UTC](https://discuss.tryton.org/t/date-format-is-wrong/4172/10 "2021-07-31T18:17:29Z")

</div>

I put this in the bug tracker

> **[tryton-client doesn't recognise changes to date format (#10615) · Issues ·...](https://foss.heptapod.net/tryton/tryton/-/issues/10615)**
>
> Tested with desktop client on Debian GNU/Linux (buster) and Python 3.7.3 Testing versions of the client between 5.0.4 and 5.8.12: changing the date format (Administration/Localization/Languages/English) doesn't...

---

<div class="post-metadata">

**Author:** ![edbo](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/e/f14d63/32.png) [@edbo](https://discuss.tryton.org/u/edbo)\
**Post date:** [August 2, 2021, 9:26am UTC](https://discuss.tryton.org/t/date-format-is-wrong/4172/11 "2021-08-02T09:26:46Z")

</div>

I am working on version 5.4 and it works perfectly. I have version 5.4.20 installed on the server and the client version is 5.4.14, but 5.4.11 is also working.

But I have to say I installed some extra languages into the database so the user can choose which language to use instead of modifying existing values.  
So I tried to change the date format of English to `%d/%m/%Y` and that worked as well and it kept working after restarting the server and client.

When you do a diff of `tryton/common/datetime_.py` from version 5.0 and 6.0 you don’t see a whole lot of differences rather then changing to GTK3. So I can imagine that this is a GTK issue fixed.

---

<div class="post-metadata">

**Author:** ![pocock](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/p/a88e57/32.png) [@pocock](https://discuss.tryton.org/u/pocock)\
**Post date:** [August 2, 2021, 12:17pm UTC](https://discuss.tryton.org/t/date-format-is-wrong/4172/12 "2021-08-02T12:17:26Z")

</div>

When I download 5.8.12 onto a Debian buster system and connect to the demo5.8 server, it does not work. Is anybody else able to reproduce this result from Debian or any other environment?

When I run 5.8.12 on the Debian system, do I need to adjust anything in the client code to make it use GTK3 on this platform? Or it always use GTK3 if available?

I also tried the diff on `datetime_.py` and there was no obvious clues. I was guessing that some other classes are not correctly interacting with the properties on the date fields.

---

<div class="post-metadata">

**Author:** ![dave](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/d/ee7513/32.png) [@dave](https://discuss.tryton.org/u/dave)\
**Post date:** [August 2, 2021, 7:17pm UTC](https://discuss.tryton.org/t/date-format-is-wrong/4172/13 "2021-08-02T19:17:28Z")

</div>

> [@pocock](#):
>
> When I run 5.8.12 on the Debian system, do I need to adjust anything in the client code to make it use GTK3 on this platform? Or it always use GTK3 if available?

> **[Drop GTK+-2 (#6932) · Issues · Tryton / Tryton · GitLab](https://foss.heptapod.net/tryton/tryton/-/issues/6932)**
>
> We support GTK+-3 since a year now, I think it is time to drop GTK+-2. This will allow after to go forward with

---

<div class="post-metadata">

**Author:** ![pocock](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/p/a88e57/32.png) [@pocock](https://discuss.tryton.org/u/pocock)\
**Post date:** [August 6, 2021, 8:53am UTC](https://discuss.tryton.org/t/date-format-is-wrong/4172/14 "2021-08-06T08:53:27Z")

</div>

It looks like the process is definitely using GTK3. This is `tryton-client` version 5.0.37, it exhibits the same bug, the database is configured for `%d/%m/%Y` but the dates appear with month first.

```auto
$ lsof -p 5623 | grep -i gtk
python3 5623 daniel mem REG 253,2 26624 1059763 /usr/lib/x86_64-linux-gnu/gtk-3.0/3.0.0/immodules/im-wayland.so
python3 5623 daniel mem REG 253,2 7251000 1059773 /usr/lib/x86_64-linux-gnu/libgtk-3.so.0.2404.1
python3 5623 daniel mem REG 253,2 194182 1101333 /usr/share/locale/en_GB/LC_MESSAGES/gtk30-properties.mo
python3 5623 daniel mem REG 253,2 103610 1101334 /usr/share/locale/en_GB/LC_MESSAGES/gtk30.mo
python3 5623 daniel mem REG 253,2 676312 1074049 /usr/lib/x86_64-linux-gnu/girepository-1.0/Gtk-3.0.typelib
python3 5623 daniel mem REG 253,2 3263 133332 /usr/share/locale/en/LC_MESSAGES/gtk30.mo
python3 5623 daniel mem REG 253,2 367 133330 /usr/share/locale/en/LC_MESSAGES/gtk30-properties.mo

```

---

<div class="post-metadata">

**Author:** ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)\
**Post date:** [August 6, 2021, 9:13am UTC](https://discuss.tryton.org/t/date-format-is-wrong/4172/15 "2021-08-06T09:13:44Z")

</div>

I tested on 5.0 series with the demo server and I can not reproduce. The only case where the format was not changed is because the user was not linked to any language so it use the client system format which is expected.

---

<div class="post-metadata">

**Author:** ![pocock](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/p/a88e57/32.png) [@pocock](https://discuss.tryton.org/u/pocock)\
**Post date:** [August 6, 2021, 9:33am UTC](https://discuss.tryton.org/t/date-format-is-wrong/4172/16 "2021-08-06T09:33:15Z")

</div>

> [@ced](#):
>
> The only case where the format was not changed is because the user was not linked to any languag

Thanks, that is a useful tip. In this case, I was using the `admin` account to evaluate Tryton. The `admin` account is created by default without specifying a language.

After setting the language for `admin` to English the dates are displayed correctly.

> [@ced](#):
>
> so it use the client system format which is expected

On the test system, other applications are always using `%d/%m/%Y`. In fact, when Tryton creates an invoice it also has the date in the correct format. This is the environment:

```auto
$ locale
LANG=en_GB.UTF-8
LANGUAGE=en_GB:en
LC_CTYPE="en_GB.UTF-8"
LC_NUMERIC="en_GB.UTF-8"
LC_TIME="en_GB.UTF-8"
LC_COLLATE="en_GB.UTF-8"
LC_MONETARY="en_GB.UTF-8"
LC_MESSAGES="en_GB.UTF-8"
LC_PAPER="en_GB.UTF-8"
LC_NAME="en_GB.UTF-8"
LC_ADDRESS="en_GB.UTF-8"
LC_TELEPHONE="en_GB.UTF-8"
LC_MEASUREMENT="en_GB.UTF-8"
LC_IDENTIFICATION="en_GB.UTF-8"
LC_ALL=

```

---

<div class="post-metadata">

**Author:** ![pocock](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/p/a88e57/32.png) [@pocock](https://discuss.tryton.org/u/pocock)\
**Post date:** [August 6, 2021, 2:15pm UTC](https://discuss.tryton.org/t/date-format-is-wrong/4172/17 "2021-08-06T14:15:10Z")

</div>

another thing that comes to mind: why did it work for me with the 6.0 client? In demo6.0 the admin user does not have any language in the preferences. Therefore, there is some code change between 5.8 and 6.0 that makes it work in 6.0

---

<div class="post-metadata">

**Author:** ![pocock](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/p/a88e57/32.png) [@pocock](https://discuss.tryton.org/u/pocock)\
**Post date:** [August 7, 2021, 2:17pm UTC](https://discuss.tryton.org/t/date-format-is-wrong/4172/18 "2021-08-07T14:17:54Z")

</div>

Here is some more feedback from Python, it looks like Python doesn’t do the right thing for `en_GB.UTF-8`:

```auto
$ python3
Python 3.7.3 (default, Jan 22 2021, 20:04:44) 
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.

>>> import locale
>>> locale.getlocale()
('en_GB', 'UTF-8')

>>> import datetime
>>> x = datetime.datetime.now()
>>> print(x.strftime("%x"))
08/07/21
>>> 

```

That is m=8/d=7/y=21 - I would expect 7/8/21 in the UK

---

<div class="post-metadata">

**Author:** ![nicoe](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/nicoe/32/2880_2.png) [@nicoe](https://discuss.tryton.org/u/nicoe)\
**Post date:** [August 9, 2021, 10:40am UTC](https://discuss.tryton.org/t/date-format-is-wrong/4172/19 "2021-08-09T10:40:00Z")

</div>

You must call `locale.setlocal(locale.LC_ALL, '')` to load the locale definition in python.  
The tryton client does it for you.

---

<div class="post-metadata">

**Author:** ![pocock](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/p/a88e57/32.png) [@pocock](https://discuss.tryton.org/u/pocock)\
**Post date:** [August 10, 2021, 7:37pm UTC](https://discuss.tryton.org/t/date-format-is-wrong/4172/20 "2021-08-10T19:37:29Z")

</div>

Here is the output on the system where I run the client:

```auto
$ python3
Python 3.7.3 (default, Jan 22 2021, 20:04:44) 
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import locale

>>> locale.setlocale(locale.LC_ALL, '')
'en_GB.UTF-8'
>>> locale.getlocale()
('en_GB', 'UTF-8')
>>> import datetime
>>> x = datetime.datetime.now()
>>> print(x.strftime("%x"))
09/08/21

```

Therefore, using `locale.setlocale` appears to fix the output

Why is this working in 6.x but not in 5.8.x? Was this call to `locale.setlocale(...)` only added in 6.x?

[Next page](https://discuss.tryton.org/t/date-format-is-wrong/4172.md?page=2)
