Any way to output timestamp to user's timezone?

Options
Is there an easy way, on the back end, for Xano to figure out what timezone a request is being made from, then filter the timestamp output to be in the timezone of the user? 
For example: user creates content and the timestamp is logged in Xano as "now." I'm using a "format_timestamp" filter to make it human readable. I'm also doing a few other things where I'd like my app to be smart enough to do something at midnight, local user time. 

My thought was that since the IP is being sent in the header of the API, I should be able to approximate the timezone. Doable with Xano?

Comments

  • Josh Chambers
    Josh Chambers Member
    Options
    Well...if anyone wants to do this:

    You can create a variable and get the info from the header, then just pass that IP into an API that converts it to a timezone, and voi la. 

    Good talk 😆
  • Michael Udinski
    Michael Udinski Administrator

    ADMIN

    Options
    Awesome!
  • Kyan Lynch
    Kyan Lynch Member
    Options
     this is great! Could you expand on your solution a little bit? I've been trying to do this and failing.
  • Josh Chambers
    Options
     Yup. Here are the first parts of that stack:

    1.  Get's the IP from the API request. In my case, I just found the IP addy in the API request, then used the "import JSON" to map the path, and used the GET to grab it. 

    [Screen Shot 2022-06-13 at 2.39.35 PM.png]2. I then used https://ipgeolocation.io/ to convert the IP address. There are a lot of these APIs, but this one worked for what I needed.[Screen Shot 2022-06-13 at 2.39.56 PM.png]3. I'm doing other things with the results, but just so you can see an example, here's me formatting the timestamp timezone using the results from the API in step #2:
    [Screen Shot 2022-06-13 at 2.40.23 PM.png]
  • Abdullah Abdulkarim
    Options

    What I did on my end was pull the Timezone from the local device using a localization package. From there I saved the timezone to the user's profile (and it updates whenever the user opens the app). I then use that as a variable to set which timezone to use & show in all the API date-related requests