web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Got a recipe for conve...
Power Automate
Unanswered

Got a recipe for converting a unix timestamp to a utc date

(1) ShareShare
ReportReport
Posted on by 6

I have a json response that contains a date in unix timestamp format, anyone know how to convert it?

I tried converttoutc but it throws errors and I cant save the expression.

If that function doesnt work, anyone have a flow recipe to do this ?  Is it possible ?

Categories:
I have the same question (0)
  • v-yuazh-msft Profile Picture
    on at

    Hi @Binaryjam,

     

    I have made a test on my side and I afraid that there is no any way to convert a unix timestamp to a utc date in microsoft flow currently.

     

    Converting a unix timestamp to a utc date is not supported in microsoft flow.

    I afraid that there is no way to achieve your needs in Microsoft Flow currently.

     

    If you would like this feature to convert a unix timestamp to a utc date to be added in Microsoft Flow, please submit an idea to Flow Ideas Forum:

    https://powerusers.microsoft.com/t5/Flow-Ideas/idb-p/FlowIdeas

     

    Best regards,

    Alice

  • GabrielStJohn Profile Picture
    on at

    Hello, @Binaryjam!

    Have you had an opportunity to apply @v-yuazh-msft's recommendation to adapt your Flow? If yes, and you find that solution to be satisfactory, please go ahead and click “Accept as Solution” so that this thread will be marked for other users to easily identify!


    Thank you for being an active member of the Flow Community!

    -Gabriel
    Flow Community Manager

  • Verified answer
    DamnThisRegistr Profile Picture
    29 on at

    Yeh I reviewed it,  its wrong,  its totally possible to do this in flow, its just a bit of maths and thats all.

     

    addseconds('1970-1-1', Div(timestamp,1000) , 'yyyy-MM-dd')

     

    I figured it out eventually. 

  • Dalrymps Profile Picture
    2 on at

    Any recommendations as to how you would then convert this into a different time zone?

  • cotton_gin1 Profile Picture
    21 on at

    Here is a good example I was able to make use of based on my timestamp:

    "last_occurrence_timestamp": 1550573979

     

    Convert this time to '2019-02-19 10:59:39' by using the following calculation

     

    addseconds('1970-1-1', Div(triggerBody()?['data']?['item']?['last_occurrence_timestamp'],1),'yyyy-MM-dd hh:mm:ss')
  • Community Power Platform Member Profile Picture
    on at

    Hi @cotton_gin1 , 

    What Action do you use? I have a Unix timestamp as output from a Parse JSON Action but which Action do I use to convert using addseconds?

    Thanks!

  • cotton_gin1 Profile Picture
    21 on at

    @ericonline,

     

    It could be a Compose action to call this out for validation but you could use Set Variable as well. Any place where you are using Dynamic Content, you can switch to using an Expression.

  • Community Power Platform Member Profile Picture
    on at

    Perfect, thank you!

  • Community Power Platform Member Profile Picture
    on at

    Hi @cotton_gin1 .

    Hm. I cannot seem to get this working using the recipe you provided (edited for my use case of course). 

    Can you identify what I'm missing?

    Trigger: Button

    Action1: HTTP Request
    Action2: Parse JSON

    • Here is where I get the Unix timestamp in a `time` parameter
    • Example output:
      • {
         "type": "FeatureCollection",
         "metadata": {
         "generated": 1557358894000,
         "url": "https://earthquake.usgs.gov/fdsnws/event/1/query?format=geojson&starttime=2019-05-07T00%3a00%3a00.0000000&endtime=5%2f8%2f2019&latitude=39.0422528&longitude=-95.6719104&maxradiuskm=1000&orderby=magnitude-asc",
         "title": "USGS Earthquakes",
         "status": 200,
         "api": "1.8.1",
         "count": 1
         },
         "features": [
         {
         "type": "Feature",
         "properties": {
         "mag": 2.9,
         "place": "16km N of Snyder, Texas",
         "time": 1557260837307,
         "updated": 1557331308692,
         "tz": -360,
         "url": "https://earthquake.usgs.gov/earthquakes/eventpage/us70003i1i",
         "detail": "https://earthquake.usgs.gov/fdsnws/event/1/query?eventid=us70003i1i&format=geojson",
         "felt": 1,
         "cdi": 2.7,
         "mmi": null,
         "alert": null,
         "status": "reviewed",
         "tsunami": 0,
         "sig": 130,
         "net": "us",
         "code": "70003i1i",
         "ids": ",us70003i1i,",
         "sources": ",us,",
         "types": ",dyfi,geoserve,origin,phase-data,",
         "nst": null,
         "dmin": 0.028,
         "rms": 0.48,
         "gap": 36,
         "magType": "mb_lg",
         "type": "earthquake",
         "title": "M 2.9 - 16km N of Snyder, Texas"
         },
         "geometry": {
         "type": "Point",
         "coordinates": [
         -100.9142,
         32.8648,
         1.96
         ]
         },
         "id": "us70003i1i"
         }
         ]
        }

    Action3: Apply to Each

    • Using the Parse JSON output
    • Action4: Compose
      • I've tried the following 3 combinations to convert the Unix timestamp to no avail:
      • **Your Recipe:** `addseconds('1970-1-1', Div(triggerBody()?['data']?['item']?['last_occurrence_timestamp'],1),'yyyy-MM-dd hh:mm:ss')`
        
        **Test 1:** `addseconds('1970-1-1', items('Apply_to_each')?['properties']?['time'],'yyyy-MM-dd hh:mm:ss')`
        **RESULTS:** `InvalidTemplate. Unable to process template language expressions in action 'Compose' inputs at line '1' and column '2590': 'Value to add was out of range.
        Parameter name: value'.`
        
        **Test 2:** `addseconds('1970-1-1', Div(items('Apply_to_each')?['properties']?['time'],1),'yyyy-MM-dd hh:mm:ss')`
        **RESULTS:** `InvalidTemplate. Unable to process template language expressions in action 'Compose' inputs at line '1' and column '2590': 'Value to add was out of range.
        Parameter name: value'.`
        
        **Test 3:** `addseconds('1970-1-1', item()?['properties']?['time'],'yyyy-MM-dd hh:mm:ss')`
        **RESULTS:** `InvalidTemplate. Unable to process template language expressions in action 'Compose' inputs at line '1' and column '2590': 'Value to add was out of range.
        Parameter name: value'.`
    • I've also tried Compose, Set Variable, and Initialize Variable Actions before the Apply to Each action. No Go.

    Any ideas? 
    Thank you!

  • cotton_gin1 Profile Picture
    21 on at

    @ericonline 

    That time field listed in your JSON is different than the one I was using. 

     

    Change your formula to divide by 1000.

    `addseconds('1970-1-1', Div(triggerBody()?['data']?['item']?['last_occurrence_timestamp'],1000),'yyyy-MM-dd hh:mm:ss')`

     

    That should work.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard