My application needs to send a daily email to users at a time of their choosing, the timezone is also defined by the user itself.
What's the best way to store HH:MM + timezone? And how can I effectively query this, knowing that my server is in a specific timezone?
My current table is:
CREATE TABLE "reminder" (
"id" SERIAL UNIQUE PRIMARY KEY,
"user" INT NOT NULL REFERENCES "user"(id) ON DELETE CASCADE,
"scheduled_at TIMESTAMPTZ NOT NULL,
"created_at" TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP
)
I'm not sure if TIMESTAMPTZ
is the most effective way to do this, since it stores the entire timestamp, and not just HH:MM