# How to print current time in EPL

**URL:** <https://community.cumulocity.com/t/how-to-print-current-time-in-epl/987>\
**Category:** Forum\
**Tags:** Streaming-Analytics-Apama, cumulocity\
**Created:** [January 18, 2024, 2:56pm UTC](https://community.cumulocity.com/t/how-to-print-current-time-in-epl/987 "2024-01-18T14:56:52Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![gabriele.chiossi](https://avatars.discourse-cdn.com/v4/letter/g/7ea924/32.png) [@gabriele.chiossi](https://community.cumulocity.com/u/gabriele.chiossi)\
**Post date:** [January 18, 2024, 2:56pm UTC](https://community.cumulocity.com/t/how-to-print-current-time-in-epl/987/1 "2024-01-18T14:56:53Z")

</div>

Hello all,  
how can I print the current time as a string?  
using “TimeFormat.format(currentTime, “yyyy-MM-dd’T’HH:mm:ss.SSS’Z’”),” does not work.  
Thank you.

---

<div class="post-metadata">

**Author:** ![Jack\_Tolfree](https://dub1.discourse-cdn.com/flex005/user_avatar/community.cumulocity.com/jack_tolfree/32/31979_2.png) [@Jack\_Tolfree](https://community.cumulocity.com/u/Jack_Tolfree)\
**Post date:** [January 18, 2024, 3:16pm UTC](https://community.cumulocity.com/t/how-to-print-current-time-in-epl/987/2 "2024-01-18T15:16:06Z")

</div>

Hello,  
Please refer to these documentation links to see if they resolve your issue, otherwise please can you provide the full line for reference.  
[Apama (softwareag.com)](https://documentation.softwareag.com/pam/10.15.4/en/webhelp/pam-webhelp/index.html#page/pam-webhelp/ta-DevApaAppInEpl_getting_the_current_time.html)  
[currentTime (softwareag.com)](https://documentation.softwareag.com/pam/10.15.4/en/webhelp/pam-webhelp/index.html#page/pam-webhelp%2Fre-ApaEplRef_currenttime.html)  
[TimeFormat](https://documentation.softwareag.com/pam/10.15.4/en/webhelp/related/ApamaDoc/com/apama/correlator/timeformat/TimeFormat.html)

Thanks,  
Jack

---

<div class="post-metadata">

**Author:** ![Nicholas\_Adams](https://avatars.discourse-cdn.com/v4/letter/n/bbce88/32.png) [@Nicholas\_Adams](https://community.cumulocity.com/u/Nicholas_Adams)\
**Post date:** [January 18, 2024, 3:18pm UTC](https://community.cumulocity.com/t/how-to-print-current-time-in-epl/987/3 "2024-01-18T15:18:07Z")

</div>

Could you elaborate a bit more on what does happen and what you are looking to achieve? Is Z intended to be a literal letter?

I’ve recently been doing just this with a slighht variance with the seconds.

```
constant string ISO_FORMAT := "yyyy-MM-dd'T'HH:mm:ss.SSSXXX";

string now := TimeFormat.format(currentTime, ISO_FORMAT);

```

---

<div class="post-metadata">

**Author:** ![Kevin\_Palfreyman](https://dub1.discourse-cdn.com/flex005/user_avatar/community.cumulocity.com/kevin_palfreyman/32/29607_2.png) [@Kevin\_Palfreyman](https://community.cumulocity.com/u/Kevin_Palfreyman)\
**Post date:** [January 18, 2024, 3:28pm UTC](https://community.cumulocity.com/t/how-to-print-current-time-in-epl/987/4 "2024-01-18T15:28:07Z")

</div>

This works:

using com.apama.correlator.timeformat.TimeFormat;

monitor MySampleMonitor {

/\*\* Initialize the application \*/

action onload() {

log "The current time is: " + TimeFormat.format(currentTime, “yyyy-MM-dd’T’HH:mm:ss.SSS’Z’”) at INFO;

}

}

(Be careful copying/pasting that you get basic ascii quote characters and note any kind of smart-quotes.)

---

<div class="post-metadata">

**Author:** ![Harald\_Meyer](https://dub1.discourse-cdn.com/flex005/user_avatar/community.cumulocity.com/harald_meyer/32/1959_2.png) [@Harald\_Meyer](https://community.cumulocity.com/u/Harald_Meyer)\
**Post date:** [January 19, 2024, 7:07am UTC](https://community.cumulocity.com/t/how-to-print-current-time-in-epl/987/5 "2024-01-19T07:07:36Z")

</div>

And another solution: if you are in Cumulocity and want to get the format Cumulocity is using, there is Util.formatTime():  
[https://documentation.softwareag.com/pam/10.15.3/en/webhelp/related/ApamaDoc/com/apama/cumulocity/Util.html#formatTime()](https://documentation.softwareag.com/pam/10.15.3/en/webhelp/related/ApamaDoc/com/apama/cumulocity/Util.html#formatTime())

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/flex005/user_avatar/community.cumulocity.com/system/32/31990_2.png) [@system](https://community.cumulocity.com/u/system)\
**Post date:** [July 17, 2024, 7:07am UTC](https://community.cumulocity.com/t/how-to-print-current-time-in-epl/987/6 "2024-07-17T07:07:52Z")

</div>

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
