# How to convert Unix timestamp to GMT formart

**URL:** <https://forums.pega.com/t/how-to-convert-unix-timestamp-to-gmt-formart/1726>\
**Category:** User Experience\
**Tags:** pega-customer-service-for-healthcare, project-delivery, healthcare-and-life-sciences, user-experience, senior-system-architect\
**Created:** [September 17, 2021, 10:54am UTC](https://forums.pega.com/t/how-to-convert-unix-timestamp-to-gmt-formart/1726 "2021-09-17T10:54:49Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vinay\_Lakka](https://avatars.discourse-cdn.com/v4/letter/v/3ab097/32.png) [@Vinay\_Lakka](https://forums.pega.com/u/Vinay_Lakka)\
**Post date:** [September 17, 2021, 10:54am UTC](https://forums.pega.com/t/how-to-convert-unix-timestamp-to-gmt-formart/1726/1 "2021-09-17T10:54:49Z")

</div>

Hi All,

I have requirement that i get Unix TimeStamp from external system and i should convert it to GMT format how does pxCreateDateTime has in clipboard. Can any one know about this? Any OOTB function avalable. Please help me.

Ex: “createDtTime”: 1631023948012,

TIA.

Regards,

Vinay LAkka

---

<div class="post-metadata">

**Author:** ![ShyjuValappil](https://yyz2.discourse-cdn.com/pega/user_avatar/forums.pega.com/shyjuvalappil/32/24072_2.png) [@ShyjuValappil](https://forums.pega.com/u/ShyjuValappil)\
**Post date:** [September 17, 2021, 6:39pm UTC](https://forums.pega.com/t/how-to-convert-unix-timestamp-to-gmt-formart/1726/2 "2021-09-17T18:39:09Z")

</div>

@VinayLakka125

I am not aware of any OOTB way to directly convert from unix time stamp. If you don’t find a better way you can convert as below,

```auto
@addToDate("19700101T000000.000 GMT",@toInt(Param.UnixTime)/86400,(@toInt(Param.UnixTime)%(86400))/3600,((@toInt(Param.UnixTime)%(86400))%(3600))/60,((@toInt(Param.UnixTime)%(86400))%(3600))%(60))

```

In the below screenshot from expression builder, Param.UnixTime is the time you mentioned above in seconds. Your time is in milliseconds. I removed last three digits to convert it to seconds.

 ![Expression Builder Screenshot.png](https://pega1.discourse-cdn.com/pega/original/2X/7/755859681d73ffe2e5d684f1b66a7ae1e04604cb.png)

Please see below screenshot for online conversion of same unix time to GMT date. I tried with different date time values and its working.

 ![Online date time conversion.png](https://pega1.discourse-cdn.com/pega/original/2X/4/470477259240da4cba53a996088e6b9f945175f5.png)

---

<div class="post-metadata">

**Author:** ![Deivit](https://yyz2.discourse-cdn.com/pega/user_avatar/forums.pega.com/deivit/32/182_2.png) [@Deivit](https://forums.pega.com/u/Deivit)\
**Post date:** [September 17, 2021, 7:10pm UTC](https://forums.pega.com/t/how-to-convert-unix-timestamp-to-gmt-formart/1726/3 "2021-09-17T19:10:25Z")

</div>

@VinayLakka125 Create a new function (ex. UnixTimestampToPegaDateTime) with 2 parameters: _timeUnix_ and _timeZone_ with the following code. This will return the Pega date time format.

```auto
// Convert the string "timeUnix" to Date
Long d = Long.parseLong(timeUnix, 10);
Date d1 = new Date(d);

// Format to fit in the appropiate PEGA type
// timeZone can be "GMT-5"
return PRDateFormat.format(null, timeZone, PRDateFormat.PEGARULES_INTERNAL_DATETIME, d1);

```

If you want to get DATE instead of DATETIME use PRDateFormat.PEGARULES\_INTERNAL\_DATE.

**Reference:** [https://community.pega.com/sites/default/files/help\_v63sp1/Content/javadocs/com/pega/pegarules/pub/util/PRDateFormat.html#format(java.lang.String,%20java.lang.String,%20java.lang.String,%20java.util.Date)](https://community.pega.com/sites/default/files/help_v63sp1/Content/javadocs/com/pega/pegarules/pub/util/PRDateFormat.html#format(java.lang.String,%20java.lang.String,%20java.lang.String,%20java.util.Date))

---

<div class="post-metadata">

**Author:** ![Vinay\_Lakka](https://avatars.discourse-cdn.com/v4/letter/v/3ab097/32.png) [@Vinay\_Lakka](https://forums.pega.com/u/Vinay_Lakka)\
**Post date:** [September 20, 2021, 7:43am UTC](https://forums.pega.com/t/how-to-convert-unix-timestamp-to-gmt-formart/1726/4 "2021-09-20T07:43:29Z")

</div>

@ShyjuV69 Thank you above fix is working in single step. I will try to convert the same logic through function.

---

<div class="post-metadata">

**Author:** ![Vinay\_Lakka](https://avatars.discourse-cdn.com/v4/letter/v/3ab097/32.png) [@Vinay\_Lakka](https://forums.pega.com/u/Vinay_Lakka)\
**Post date:** [September 20, 2021, 7:44am UTC](https://forums.pega.com/t/how-to-convert-unix-timestamp-to-gmt-formart/1726/5 "2021-09-20T07:44:06Z")

</div>

@Deivit I will try this function & get back you thank you so much.
