# Ignition Perspective Page to show the client System date and time

**URL:** <https://forum.inductiveautomation.com/t/ignition-perspective-page-to-show-the-client-system-date-and-time/73265>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [May 4, 2023, 2:33pm UTC](https://forum.inductiveautomation.com/t/ignition-perspective-page-to-show-the-client-system-date-and-time/73265 "2023-05-04T14:33:18Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![PRASHANTH\_KAKKIRALA](https://avatars.discourse-cdn.com/v4/letter/p/76d3ee/32.png) [@PRASHANTH\_KAKKIRALA](https://forum.inductiveautomation.com/u/PRASHANTH_KAKKIRALA)\
**Post date:** [May 4, 2023, 2:33pm UTC](https://forum.inductiveautomation.com/t/ignition-perspective-page-to-show-the-client-system-date-and-time/73265/1 "2023-05-04T14:33:18Z")

</div>

Is it possible to display the client computer/system date and time on perspective web page?

dateFormat(now(60000), "yyyy-MMM-dd HH:mm:ss a") showing the Gateway Server system date and time.

Under Browse Tags-\> System -\> Client Tags are not available for Perspective sessions.

---

<div class="post-metadata">

**Author:** ![kyler.kamyszek](https://avatars.discourse-cdn.com/v4/letter/k/a4c791/32.png) [@kyler.kamyszek](https://forum.inductiveautomation.com/u/kyler.kamyszek)\
**Post date:** [May 4, 2023, 2:54pm UTC](https://forum.inductiveautomation.com/t/ignition-perspective-page-to-show-the-client-system-date-and-time/73265/2 "2023-05-04T14:54:03Z")

</div>

Change the project property.

Project Properties \> Perspective \> General \> Project Timezone \> 'Client Timezone'

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [May 4, 2023, 2:59pm UTC](https://forum.inductiveautomation.com/t/ignition-perspective-page-to-show-the-client-system-date-and-time/73265/3 "2023-05-04T14:59:14Z")

</div>

`now()` is going to use the Gateway's timezone, because that's where the script is executed. I suspect you'll need to get crafty with a transform for the binding where you adjust the time based on the session timezone (`props.timeZoneId`) before formatting it.

---

<div class="post-metadata">

**Author:** ![PRASHANTH\_KAKKIRALA](https://avatars.discourse-cdn.com/v4/letter/p/76d3ee/32.png) [@PRASHANTH\_KAKKIRALA](https://forum.inductiveautomation.com/u/PRASHANTH_KAKKIRALA)\
**Post date:** [May 4, 2023, 3:31pm UTC](https://forum.inductiveautomation.com/t/ignition-perspective-page-to-show-the-client-system-date-and-time/73265/4 "2023-05-04T15:31:20Z")

</div>

Thanks, cmallonee. Can you explain little more detailed. I'm little new to ignition.

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [May 4, 2023, 3:57pm UTC](https://forum.inductiveautomation.com/t/ignition-perspective-page-to-show-the-client-system-date-and-time/73265/5 "2023-05-04T15:57:46Z")

</div>

I'm actually out of the office until next week so I won't be able to supply a code example until then. In theory, you'll configure your binding to be an expression which contains _only_ `now(60000)`. In a transform of that binding, you'll need to use available date and time libraries to modify the incoming value based on the difference between the Gateway's timezone id (`self.session.props.gateway.timezone.id`), and that of the Session (`self.session.props.timeZoneId`) before finally either formatting this new value and returning it, or returning the modified value into yet another transform where you format it into the desired string pattern.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [May 4, 2023, 4:11pm UTC](https://forum.inductiveautomation.com/t/ignition-perspective-page-to-show-the-client-system-date-and-time/73265/6 "2023-05-04T16:11:20Z")

</div>

> [@cmallonee](#):
>
> modify the incoming value

In the transform, I recommend converting the [Date to an Instant](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/Date.html#toInstant()), then [to a ZonedDateTime](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/time/Instant.html#atZone(java.time.ZoneId)) object with the [ZoneId selected by](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/time/ZoneId.html#of(java.lang.String)) `self.session.props.timeZoneId`.

String conversion of the ZonedDateTime will use the client's timezone.

The transform would look like this:

```auto
from java.time import ZoneId
return value.toInstant().atZone(ZoneId.of(self.session.props.timeZoneId))

```

---

<div class="post-metadata">

**Author:** ![PRASHANTH\_KAKKIRALA](https://avatars.discourse-cdn.com/v4/letter/p/76d3ee/32.png) [@PRASHANTH\_KAKKIRALA](https://forum.inductiveautomation.com/u/PRASHANTH_KAKKIRALA)\
**Post date:** [May 4, 2023, 5:36pm UTC](https://forum.inductiveautomation.com/t/ignition-perspective-page-to-show-the-client-system-date-and-time/73265/7 "2023-05-04T17:36:01Z")

</div>

Thanks. It's working but formatting using Java methods is not working in perspective.  
Can you share formatting logic example as well?

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [May 4, 2023, 6:13pm UTC](https://forum.inductiveautomation.com/t/ignition-perspective-page-to-show-the-client-system-date-and-time/73265/8 "2023-05-04T18:13:48Z")

</div>

Sure. I recommend [DateTimeFormatter.ofPattern()](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/time/format/DateTimeFormatter.html#ofPattern(java.lang.String)). But I would move the complexity to a project script module with a DateTimeFormatter instance with your preferred pattern saved as a top level variable. Like so, perhaps:

```auto
from java.time import ZoneId
from java.time.format import DateTimeFormatter

defaultFormatter = DateTimeFormatter.ofPattern("YYYY-MM-dd HH:mm")

def zonedFormat(ts, zoneid, format=None):
	formatter = defaultFormatter if format is None else DateTimeFormatter.ofPattern(format)
	return ts.toInstant().atZone(ZoneId.of(zoneid)).format(formatter)

```

If that is a project script named `zoneHelper`, then your transform becomes just:

```auto
return zoneHelper.zonedFormat(value, self.session.props.timeZoneId)

```

Use the optional third argument to supply a different format pattern.

---

<div class="post-metadata">

**Author:** ![PRASHANTH\_KAKKIRALA](https://avatars.discourse-cdn.com/v4/letter/p/76d3ee/32.png) [@PRASHANTH\_KAKKIRALA](https://forum.inductiveautomation.com/u/PRASHANTH_KAKKIRALA)\
**Post date:** [May 5, 2023, 8:19am UTC](https://forum.inductiveautomation.com/t/ignition-perspective-page-to-show-the-client-system-date-and-time/73265/9 "2023-05-05T08:19:23Z")

</div>

> [@PRASHANTH\_KAKKIRALA](#):
>
> yyyy-MMM-dd HH:mm:ss a

It worked finally. I had to make few changes to the suggested code. Thanks

```auto
def transform(self, value, quality, timestamp):
	from java.time import ZoneId
	from java.time.format import DateTimeFormatter
	
	defaultFormatter = DateTimeFormatter.ofPattern("yyyy-MMM-dd HH:mm:ss a")
	zoneid=self.session.props.device.timezone.id
#	def zonedFormat(ts, zoneid, format=None):
	#formatter = DateTimeFormatter.ofPattern(defaultFormatter)
	client_time = value.toInstant().atZone(ZoneId.of(zoneid)).format(defaultFormatter)
	return client_time

```

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [May 5, 2023, 12:40pm UTC](https://forum.inductiveautomation.com/t/ignition-perspective-page-to-show-the-client-system-date-and-time/73265/10 "2023-05-05T12:40:16Z")

</div>

I strongly recommend you use a project library script as I showed. Imports and pattern creation are heavy-weight operations in jython that you don't want to be doing on every execution of the transform.

---

<div class="post-metadata">

**Author:** ![PRASHANTH\_KAKKIRALA](https://avatars.discourse-cdn.com/v4/letter/p/76d3ee/32.png) [@PRASHANTH\_KAKKIRALA](https://forum.inductiveautomation.com/u/PRASHANTH_KAKKIRALA)\
**Post date:** [May 5, 2023, 4:23pm UTC](https://forum.inductiveautomation.com/t/ignition-perspective-page-to-show-the-client-system-date-and-time/73265/11 "2023-05-05T16:23:39Z")

</div>

> [@pturmel](#):
>
> `return zoneHelper.zonedFormat(value, self.session.props.timeZoneId)`

Ok, Sure. Modified the logic.  
Thanks!
