# \[IGN-6614\]What is the best way to format a date (milliseconds) for a specified timezone with Ignition's python scripting

**URL:** <https://forum.inductiveautomation.com/t/ign-6614-what-is-the-best-way-to-format-a-date-milliseconds-for-a-specified-timezone-with-ignitions-python-scripting/64068>\
**Category:** Ignition\
**Tags:** scripting, ignition81\
**Created:** [September 14, 2022, 5:40pm UTC](https://forum.inductiveautomation.com/t/ign-6614-what-is-the-best-way-to-format-a-date-milliseconds-for-a-specified-timezone-with-ignitions-python-scripting/64068 "2022-09-14T17:40:21Z")\
**Posts on this page:** 1\
**Showing post:** 7

<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:** [September 14, 2022, 6:43pm UTC](https://forum.inductiveautomation.com/t/ign-6614-what-is-the-best-way-to-format-a-date-milliseconds-for-a-specified-timezone-with-ignitions-python-scripting/64068/7 "2022-09-14T18:43:45Z")

</div>

Ah, I was overthinking things.

SimpleDateFormat extends DateFormat. DateFormat defines `setTimeZone()`.

TimeZone is an instance of `java.util.TimeZone`, and easiest obtained from an ID.

```auto
from java.util import TimeZone
from java.text import SimpleDateFormat

#for tz in TimeZone.getAvailableIDs():
#	print tz

now = system.date.now()

eastern = TimeZone.getTimeZone("America/New_York")
pacific = TimeZone.getTimeZone("America/Los_Angeles")

sdf = SimpleDateFormat("yyyy-MM-dd HH:mm:ss ZZZ")
print sdf.getTimeZone().getID()
print sdf.format(now)

sdf.setTimeZone(eastern)
print sdf.getTimeZone().getID()
print sdf.format(now)

sdf.setTimeZone(pacific)
print sdf.getTimeZone().getID()
print sdf.format(now)

```

Here in California, that gets me:

```auto
>>> 
America/Los_Angeles
2022-09-14 11:43:14 -0700
America/New_York
2022-09-14 14:43:14 -0400
America/Los_Angeles
2022-09-14 11:43:14 -0700 

```

---

_[View the full topic](https://forum.inductiveautomation.com/t/ign-6614-what-is-the-best-way-to-format-a-date-milliseconds-for-a-specified-timezone-with-ignitions-python-scripting/64068)._
