Weird behavior on timestamp

Let me explain. I'm on GMT +1 like for all my current customers.
I need somewhere to get daily records, so I go by comparing epoch days

Where date is sent from the frontend as a return Math.floor(timestamp / 1000 / 60 / 60 / 24).
However, for records in this 1 hour timezone offset, 00:35:48 GMT+1 for example, the frontend epoch day is xxx but the backend one is still xxx-1 , so I'm unable to get the right data for the customer and that could create misunderstandings while operating at that offset time.
Fortunately, I have my customers timezones(in hours) in the settings table, so with a function to get that value, I came to this.

But I can't even explain the result it produced, nothing good(for what I want to do). I replaced the timezone variable by 0 thinking it would cancel the add_hours effect but no. It is like the filter is doing something I'm not getting. I ended up removing the filter and timezone.

Am I doing something wrong? Thank you for the help

Other
15 replies