Time to next quarter hour

Options

Hi,

I have a "now" variable that gives me the current time.
I would like this variable to give me the time of the next quarter hour.

Examples

  • If it is 03:12, the variable must be 03:15
  • If it is 07:25 the variable must be 07:30

Do you have any idea how I can proceed?

Thanks :-)

Answers

  • Sean Montgomery
    Sean Montgomery Administrator

    ADMIN

    Options

    You can use the transform_timestamp filter, which lets you work with relative time. Take a look at the formats available - this should be doable.

    https://docs.xano.com/working-with-data/data-type-filters/timestamp-filters#transform_timestamp

  • 00liolio00
    00liolio00 Member
    Options

    Thanks for the answer @Sean Montgomery

    I looked at this solution but the quarter hour doesn't seem possible.
    Moreover, for information, the link in the article to the relative times format is in error 404.

    So I solved my problem as follows:

    1. I isolated the minutes and I divide these by 15.
    2. I use "ceil" to round the value.
    3. I multiply by 15
    4. I reconstruct my "now" via an extraction of the set without the minutes that I introduce by concatenation.

    Maybe my solution can help others :-)

    Good evening !

  • Ray Deck
    Ray Deck Trusted Xano Expert ✭✭✭
    Options

    SInce a timestamp is a number milliseconds, and a quarter-hour is 15 minutes, which is 900 seconds, which is 900,000 milliseconds, you can also:

    timestamp |divide 900000 | ceil | multiply 900000 to get the current time rounded up to the next quarter-hour.

    Here's a screenshot of it in Xano: