# \[bug-16147\]dateFormat() locale

**URL:** <https://forum.inductiveautomation.com/t/bug-16147-dateformat-locale/32890>\
**Category:** Ignition\
**Created:** [March 6, 2020, 4:54pm UTC](https://forum.inductiveautomation.com/t/bug-16147-dateformat-locale/32890 "2020-03-06T16:54:59Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![pdellova](https://avatars.discourse-cdn.com/v4/letter/p/54ee81/32.png) [@pdellova](https://forum.inductiveautomation.com/u/pdellova)\
**Post date:** [March 6, 2020, 4:54pm UTC](https://forum.inductiveautomation.com/t/bug-16147-dateformat-locale/32890/1 "2020-03-06T16:54:59Z")

</div>

Hi,

Is there a way to display the expression :

> dateFormat(now(0), "EEEE dd MMMM YYYY") )

in a given locale (french in my case) when java machine is in a different locale (english in my case)?

I also made few test on a VM with french java machine, try to set the wrapper localization in ignition.conf file with

> wrapper.lang=en\_US

then restart service but the date still remain in french.

any idea about this behavior?

Thanks

---

<div class="post-metadata">

**Author:** ![KathyApplebaum](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kathyapplebaum/32/7261_2.png) [@KathyApplebaum](https://forum.inductiveautomation.com/u/KathyApplebaum)\
**Post date:** [March 6, 2020, 5:35pm UTC](https://forum.inductiveautomation.com/t/bug-16147-dateformat-locale/32890/2 "2020-03-06T17:35:03Z")

</div>

Where are you trying to use this expression? In a client, I bound the text of a label to the expression you have above and dropped a language selector component on the window. When I change the language selected, the display changes from  
`Friday 06 March 2020`  
to  
`vendredi 06 mars 2020`

You should also be able to use `system.util.setLocale()`, although I didn’t test this.

---

<div class="post-metadata">

**Author:** ![pdellova](https://avatars.discourse-cdn.com/v4/letter/p/54ee81/32.png) [@pdellova](https://forum.inductiveautomation.com/u/pdellova)\
**Post date:** [March 9, 2020, 8:54am UTC](https://forum.inductiveautomation.com/t/bug-16147-dateformat-locale/32890/3 "2020-03-09T08:54:33Z")

</div>

Hi,  
Thanks for your prompt,  
I forgot to specify that I am in perspective and directly set the locale in the session props

> self.session.props.locale = "fr-FR"  
> or  
> self.session.props.locale = "en-EN"

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [March 9, 2020, 3:02pm UTC](https://forum.inductiveautomation.com/t/bug-16147-dateformat-locale/32890/4 "2020-03-09T15:02:22Z")

</div>

Create a custom session property (I used ‘session.custom.today’), then use a script transform:

```python
	from java.text import SimpleDateFormat
	from java.util import Locale
	
	# Set locale dictionary. Using Locale.variants() doesn't always work, 
	# so we use a dictionary to force the locale.

	localeDict = {
	              'fr-FR' : Locale.FRENCH, 
	              'en-EN' : Locale.ENGLISH
	             }
	
	langFormat= SimpleDateFormat('EEEE dd MMMM YYYY', localeDict[self.props.locale]) # The format you want to convert to
	return langFormat.format(value)

```

English:

 ![2020-03-09_10-55-33](https://us1.discourse-cdn.com/inductiveautomation/original/2X/3/30571f8b21ada6ad335e6dc07f97e70815202817.png)

French:

 ![2020-03-09_11-00-34](https://us1.discourse-cdn.com/inductiveautomation/original/2X/e/ec65b71cd2168b34583f96b12f7cf17e10f0b641.png)

Expression Binding:

 ![2020-03-09_11-04-25](https://us1.discourse-cdn.com/inductiveautomation/original/2X/c/c564a03f1052b303fe2b291bd69b64b1d0cdeacd.png)

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [March 9, 2020, 3:51pm UTC](https://forum.inductiveautomation.com/t/bug-16147-dateformat-locale/32890/5 "2020-03-09T15:51:09Z")

</div>

I’ll make the argument this is a bug; `dateFormat` from Perspective “should” be using the session locale prop instead of having to use @JordanCClark’s admittedly clever workaround. I filed a ticket.

---

<div class="post-metadata">

**Author:** ![pdellova](https://avatars.discourse-cdn.com/v4/letter/p/54ee81/32.png) [@pdellova](https://forum.inductiveautomation.com/u/pdellova)\
**Post date:** [March 9, 2020, 4:51pm UTC](https://forum.inductiveautomation.com/t/bug-16147-dateformat-locale/32890/6 "2020-03-09T16:51:13Z")

</div>

Hi,

Thank you @KathyApplebaum@JordanCClark and @paul-griffith for your prompt attention to the subject.  
I will use the given tip while waiting for a bug fix.

Regards,

Pierre.
