How to convert yyyy-mm-ddthh:mm:ss.sssz on laravel api or flutter view?

Issue

I build android apps using flutter and laravel rest api.
but I get start_time with this format (yyyy-mm-ddthh:mm:ss.sssz) on postman:
enter image description here

on database sql server it looks fine:

enter image description here

my flutter apps view:
enter image description here

Can some one help me to convert starttime data? this make a wrong time output. I’ve tried to change model on laravel like this. but it make error ‘500’ when user input data.
enter image description here

Solution

maybe you can try this on your flutter :

final starttime = DateTime.parse(cutiData['start_time']).toLocal();
final endtime = DateTime.parse(cutiData['end_time']).toLocal();

ANd you call in return as string:

starttime.toString(),
endtime.toString(),

Answered By – Siti Fatimah

Answer Checked By – David Goodson (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published.