# Ntp 64bits format in datetime

**URL:** <https://forum.inductiveautomation.com/t/ntp-64bits-format-in-datetime/5093>\
**Category:** Ignition\
**Created:** [September 3, 2012, 8:40am UTC](https://forum.inductiveautomation.com/t/ntp-64bits-format-in-datetime/5093 "2012-09-03T08:40:27Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![gnguyen](https://avatars.discourse-cdn.com/v4/letter/g/41988e/32.png) [@gnguyen](https://forum.inductiveautomation.com/u/gnguyen)\
**Post date:** [September 3, 2012, 8:40am UTC](https://forum.inductiveautomation.com/t/ntp-64bits-format-in-datetime/5093/1 "2012-09-03T08:40:27Z")

</div>

Hi,

How can I convert “with expression” a ntp time format (64 bits format) in human readable format with expression ?  
In python, there is no problem with time.ctime(utc\_seconds), but can’t find a simple way to make it in expression.

Thanks,

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [September 4, 2012, 3:12pm UTC](https://forum.inductiveautomation.com/t/ntp-64bits-format-in-datetime/5093/2 "2012-09-04T15:12:48Z")

</div>

I don’t think you can right now. However, you can run a script in an expression. So if you make a global script function that will return the time you can call it in an expression:`runScript("app.time.convert()", 0)`The second argument is for polling if you want to turn it on.

---

<div class="post-metadata">

**Author:** ![gnguyen](https://avatars.discourse-cdn.com/v4/letter/g/41988e/32.png) [@gnguyen](https://forum.inductiveautomation.com/u/gnguyen)\
**Post date:** [September 5, 2012, 5:29am UTC](https://forum.inductiveautomation.com/t/ntp-64bits-format-in-datetime/5093/3 "2012-09-05T05:29:22Z")

</div>

Travis,

I think there is something to obvious to be seen…

My global function is defined as follow in app.conv :

[quote]def utc2date(utc\_hex):  
import time  
return (time.ctime(int(utc\_hex,16)))[/quote]  
and a call in script playgroung or behind a button is working well.  
If I put it in an expression tag, I have an evaluation error and can’t see any log for this error.

Any clue ![:scratch:](https://us1.discourse-cdn.com/inductiveautomation/original/1X/76d1620bec252bfac07050c889ff5a91dc8a9c25.gif ":scratch:")

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [September 5, 2012, 4:52pm UTC](https://forum.inductiveautomation.com/t/ntp-64bits-format-in-datetime/5093/4 "2012-09-05T16:52:46Z")

</div>

Can you paste the exact expression? The problem probably lies with how you pass in variables into your function.

---

<div class="post-metadata">

**Author:** ![gnguyen](https://avatars.discourse-cdn.com/v4/letter/g/41988e/32.png) [@gnguyen](https://forum.inductiveautomation.com/u/gnguyen)\
**Post date:** [September 5, 2012, 5:25pm UTC](https://forum.inductiveautomation.com/t/ntp-64bits-format-in-datetime/5093/5 "2012-09-05T17:25:18Z")

</div>

Yes sure.

The SQLtag is a string, as ctime return a string and the expression is

> [@](#):
>
> runScript("app.conv.utc2date('FFD3E345')",0)

The parameter 'FFD3E345' is a static and arbritary one for my test, but in reality it comes from an opc tag in a string format.

A print runScript("app.conv.utc2date('FFD3E345')",0) in the playground is ok.

 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/e/e0ad2470b6bb808b33994a162be284bf27999e45.png)

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [September 5, 2012, 6:33pm UTC](https://forum.inductiveautomation.com/t/ntp-64bits-format-in-datetime/5093/6 "2012-09-05T18:33:50Z")

</div>

Oh I see. I thought the expression was on the window. You can’t call app functions from SQLTags. SQLTags are not part of a project so they don’t know about the script module functions. However, there is a way to run the script directly in the expression without calling a global script function. Here is an example:`runScript("0\nimport time\n__RESULT=(time.ctime(int('FFD3E345',16)))", 0)`

---

<div class="post-metadata">

**Author:** ![gnguyen](https://avatars.discourse-cdn.com/v4/letter/g/41988e/32.png) [@gnguyen](https://forum.inductiveautomation.com/u/gnguyen)\
**Post date:** [September 5, 2012, 7:30pm UTC](https://forum.inductiveautomation.com/t/ntp-64bits-format-in-datetime/5093/7 "2012-09-05T19:30:11Z")

</div>

Ah nice ! just tested and it just works !

Thank you ![:prayer:](https://us1.discourse-cdn.com/inductiveautomation/original/1X/e5a7e3b63facc151ea73e3b45db7bdb3d4bdc316.gif ":prayer:")
