George
Explore posts from serversTTCTheo's Typesafe Cult
•Created by George on 9/13/2024 in #questions
Handling Dates with client and server and database
Hello, so i am trying to create an appointment scheduling website and I am having trouble using dates between the client and the server.
When I first implemented my endpoints, I made sure to convert any date I pass from the client to the server using a zod schema that converts said date to UTC for me.
Then I deal with my app logic (using date-fns to handle dates) and save the date or make any db queries using this UTC date. This was working completely fine when working locally.
But once I deployed the app, the dates for available appointment slots were completely different. I assumed it was because the timezone my deployed server is a different timezone to the client.
Now I think that the date modifications I am making within my endpoint logic is invalid since I am using date-fns and it is calculating the modifications based on the server's timezone.
So I am wondering what the best practise is to handling dates between client and server.
Should i just not use date-fns and handle dates on my own? (Could not find an easy way to use date-fns for a specific timezone)
Should I accept a date as it is and only convert to UTC once I need to query or enter data into the database?
Thanks for the help.
2 replies
DTDrizzle Team
•Created by George on 12/3/2023 in #help
How to create unique constraint on a column for a foreign key?
3 replies
TTCTheo's Typesafe Cult
•Created by George on 11/20/2023 in #questions
How to set the generated vercel preview url as the env variable for NEXTAUTH_URL
6 replies
DTDrizzle Team
•Created by George on 11/19/2023 in #help
Generate drizzle migrations and push with drizzle kit with github actions for preview environments
6 replies
TTCTheo's Typesafe Cult
•Created by George on 10/21/2023 in #questions
Does anyone have a working example repo of T3 stack with drizzle and postgres?
I am trying move away from prisma, so I decided to create a new repo with drizzle instead and incrementally move over my code and changes prisma to drizzle. However after trying this I could not find many examples of using drizzle with postgres.
The T3 stack now has drizzle support on init through the cli, but its made with mysql2 in mind. Also there are no docs for drizzle on the T3 site as of now. After looking online I can see many different ways of connecting to postgres and its very confusing.
I also am going to be using neon for my postgres db, if that changes anything.
I am also having trouble with applying the migration files once it has been generated.
Just wondering if anyone has attempeted this and could point me in the right direction. Thanks.
Just wondering if anyone has attempeted this and could point me in the right direction. Thanks.
4 replies
TTCTheo's Typesafe Cult
•Created by George on 8/23/2023 in #questions
Email Attachments without creating a file
4 replies
TTCTheo's Typesafe Cult
•Created by George on 8/2/2023 in #questions
Setting default roles on signUp, NextAuth
13 replies
TTCTheo's Typesafe Cult
•Created by George on 7/14/2023 in #questions
The keyword 'import' is reserved
2 replies
TTCTheo's Typesafe Cult
•Created by George on 6/18/2023 in #questions
utils from api.useContext() not working?
2 replies
TTCTheo's Typesafe Cult
•Created by George on 3/7/2023 in #questions
Role is undefined when using NextAuth
10 replies
TTCTheo's Typesafe Cult
•Created by George on 3/4/2023 in #questions
Unable to connect to Postgres DB with prisma
I just installed pgAdmin 4 and created a db, however once I run
npx prisma migrate dev
I get the error User 'johndoe' was denied access on the database 'db.public'
. Here is my database_url: postgresql://user:password@localhost:5432/db?schema=public
. I also made sure that special characters have been converted inside % signs. Am I doing something wrong? Is there a specific way I need to create the database? Please help, thankyou.7 replies
TTCTheo's Typesafe Cult
•Created by George on 3/3/2023 in #questions
Objects of objects of a certain type
23 replies
TTCTheo's Typesafe Cult
•Created by George on 2/28/2023 in #questions
How do I type T3 App with nestable layouts for each route?
1 replies