How to change the timezone that a cloud function with dart-runtime uses when creating DateTime objects? I have already changed the timezone fo the host, appwrite seems to have its own timezone configured?
Changing timezone in cloud function runtimes..
Can you expand further on what you're trying to do and what's going on?
When server-side, you should always work in UTC
I have a cloud function that runs on the dart-runtime. There I use DateTime objects to make changes. The created DateTime objects are three hours behind my local timezone
At first I thought the dart runtime reflects the system's timezone, just as how it does so on my own machine, but on appwrite it seems to be somewhat diffeernt
What exactly are you doing with the datetime objects? You should probably be doing DateTime().toUtc()
Already doing that. I use the DateTime object to query based on the local timezone
.toUtc() still returns the time that is behind my timezone
What do you mean?
Sorry if I have not been clear.
The cloud function uses the current DateTime (the time it gets triggered) and uses it to find the documents that belong to the same DateTime (that's; $createdAt attribute). And the problem is that the DateTime in my dart runtime is three hours behind my local timezone, so whenever users trigger that function in the local timezone, the queried result will be inaccurate since it's going to be based on a DateTime with a different timezone. I hope it's clear
Belong to the same timezone? What do you mean? Can you explain in more detail what you're trying to do?
Let's say my documents are created at different times in day 1, And a user wants to query to the documents at a specific time, for that the user calls a cloud function to do that for him.. the cloud function does not take any input from the user but rather uses the current time it gets triggered and queries the docs per that.
when the cloud function uses the current datetime, the result is not going to be the same as if the user has passed into the function its dateTime
because as I described previously, in my console the DateTime (if I print out thru the dart runtime) appears 3 hours behind the time zone I need to operate in
I'm currently just doing res.json({
'areDevelopersAwesome': DateTime.now().toUtc().toString(),
}); in my cloud function and the dateTime ain't the same as my host
Did I make the use-case clearer? @Steven
The user must supply the input
it seems to be the way I shall go with
I will go this way now. I appreciate the time you took here 👋
Recommended threads
- AppwriteException - Transaction with the...
I am using "node-appwrite" module and I have successfully created transaction id but when passing it to tablesDB.createRow function with some other required dat...
- Cannot create cloud function due to this...
As I try to deploy a new function to Github I get this error message: ``` Unable to clone code repository: fatal: ' ' is not a valid branch name hint: See `man ...
- How to use TS for creating appwrite func...
I was making a few appwrite functions but on doing the appwrite init setup process i always got main.js. Is there any way i can use TS?