Not having the same DateTime in Localhost vs Railway app deployed.

I'm sending a request to my backend using dayjs, I send the request in format DD-MM-YYYY, in localhost I'm having this response: { startDate: 2023-03-26T03:00:00.000Z } { endDate: 2023-03-27T02:59:59.999Z } Which makes sense to me since I'm GMT -3 Now, when the app is deployed and I send the same request I have the following dateTime: { startDate: 2023-03-26T00:00:00.000Z } { endDate: 2023-03-26T23:59:59.999Z } Which I feel is UTC. The stack I'm using is MERN. To work with date time I'm using dayjs. This is the code const startDate = dayjs(req.query.date as string, 'DD-MM-YYYY') .startOf('day') .toDate(); const endDate = dayjs(req.query.date as string, 'DD-MM-YYYY') .endOf('day') .toDate(); console.log({ startDate }); console.log({ endDate }); const orders = await Order.find({ date: { $gte: startDate, $lte: endDate }, }); return res.status(200).json(orders);
7 Replies
Percy
Percy16mo ago
Project ID: N/A
Percy
Percy16mo ago
⚠️ experimental feature
Brody
Brody16mo ago
yes it is utc, because that's what the system time of the apps container is if you want to get a specific timezone from your app when running on railway, dayjs has a timezone plugin for that
imIgnacio
imIgnacio16mo ago
Oh, so I'd need to use the timezone plugin and use it when running starting the app in railway?
Brody
Brody16mo ago
sounds about right
imIgnacio
imIgnacio16mo ago
Thanks Brody
Brody
Brody16mo ago
no problem!
Want results from more Discord servers?
Add your server
More Posts