Opening Times fraction calculations

Hi Everyone. Trying to set up my app to only accept orders during opening hours.

In order to do this I want to hide my checkout button if the current time is not between the opening and closing hours.


If the checkout button is hidden then we will be able to see this message above letting the user now when it opens again.

To achieve this I used some advice from this forum to calculate time fractions.

So when the merchant sets up their opening/closing times I have this calculation:

Which provides me with the opening/closing time number fraction.
My Problem is when I calculate the current time fraction on my page. I get a different number as if I did it for the merchant.

IE:
If I calculate at 9am UK time I get
0.354166666667879 in the merchant date picker
and
0.32451388888876 calculating it from current time.

Can anyone help?

Before I dig up my math books, I wanted to quickly confirm if you managed to get this working or not yet? Otherwise I will try to jump in and have a go.

Hi Colin, I ended up using an external api and it seems to work now :smile:

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.