Update field to Xano timezone

Options
Hi,
I have an app that is global, so users have different timezones. I made a table "user" with their data and the respective timezone. How can I build a function that will update the timestamp field from the user timezone to xano timezone? 

Thank you very much in advance.

Comments

  • Thierry MARTIN
    Options
    Hi JJ,
    A timestamp is an absolute value. It's not timezone dependant. It's the number of milliseconds between january 1st 1970 UTC and the specified UTC date-time.

    Therefore, you can provide an ISO 8601 date-time string (including the timezone) to Xano to get the relevant timestamp.

    You should read this page. It's probably clearer than my explanation ;)
    https://docs.xano.com/working-with-data/timestamp
  • JJ
    JJ Member
    Options
     thanks, I know timestamp is not timezone dependant, but my issue is if I want to add let's say a datetime data from external app to XANO DB and then compare to XANO "now" timestamp, XANO has to have the "now" in a certain timezone and that is what I need to know/convert to not compare Apples with Oranges.

    [image.png]
  • Thierry MARTIN
    Options
    The to_timestamp filter lets you specify from which timezone comes your local "now" date-time.
    If your date-time is provided in a standard ISO 8601 string format and includes the timezone (for example 2021-01-01T14:00:00-0400), you'll get the correct timestamp.
    [image.png]
  • JJ
    JJ Member
    Options
    Super thank you very much, was able to achieve what I needed with to_timestamp and add_secs_to_timestamp 😃.