Hi,
I get back a datetime from appwrite in this format 2023-01-06T14:30:00.000+00:00
and I need to end up with a Flutter dateTime. I tried this String utcDateString = '2023-01-06T14:30:00.000+00:00';
DateTime utcDate = DateTime.parse(utcDateString);
but it is not working. Any ideas?
I was able to get it working with use of substrings but seems like not a good way to do it. ```DateTime isoToFlutterDateTime({required String date}) { final reformat = '${date.substring(0, 4)}-${date.substring(5, 7)}-${date.substring(8, 10)} ${date.substring(11, 16)}';
final dateParse = DateTime.parse(reformat);
return dateParse; }```
This function seems to do the trick
String formatDateTimeFromUtc(dynamic time){
try {
return new DateFormat("yyyy-MM-dd hh:mm:ss").format(new DateFormat("yyyy-MM-dd'T'HH:mm:ss").parse(time));
} catch (e){
return new DateFormat("yyyy-MM-dd hh:mm:ss").format(new DateTime.now());
}
}
What's wrong with the parse?
Sorry the parse method is working. I was doing something else wrong. 😆
Hi, @djcali do you need any more help regarding this
No thanks! problem solved.
[SOLVED] How to convert Appwrite datetime to Flutter datetime?
Recommended threads
- Current User is Not authorized
recreating same Thread
- Apple OAuth Scopes
Hi Hi, I've configured sign in with apple and this is the response i'm getting from apple once i've signed in. I cant find anywhere I set scopes. I remember se...
- Sign In With Apple OAuth Help
Hi All! I've got a flutter & appwrite app which Im trying to use sign in with apple for. I already have sign in with google working and the function is the sam...