Back

Datetime issue

  • 0
  • Flutter
Hassanmrwt
4 Mar, 2023, 17:14

I am facing in issue with appwrite when I store datetime type from front end and the backend side is Daytime type it gives error. When I have attribute with integer type it gives an error also with Datetime.now() #🗂│support #support @Eldad @Aditya Oberai

TL;DR
The user is facing an issue with storing datetime types in Appwrite. When using the DateTime.now() method, it gives an error. The solution is to use the DateFormat library to format the date and time into an ISO string before storing it in Appwrite.
joeyouss
6 Mar, 2023, 13:43

Hi, thank you for your question. Date.now() is unix timestamp - seconds/milliseconds since specific date. What datetime attribute needs is ISO string of date.

TypeScript
var now = new DateTime.now();
var dateFormatted = DateFormat("yyyy-MM-ddTHH:mm:ss").format(now);

then you use dateFormatted as value for DateTime attribute in Appwrite, and it should work.

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more