Issue
I have a container/text thats being brought back from as part of a list view. It builds a dynamic list from the database. The .createAt is the datetime.
alignment: Alignment.topLeft,
child: Text(
sl<IIndividualDataProvider>()
.reads[index]
.createdAt,
),
),
)
For the life of me I cannot get this into a US date format of mm-dd-yyyy.
Any clues as to what i am missing? I've been playing with DateFormat but dont understand how to wrap the result of
sl<IIndividualDataProvider>().reads[index].createdAt,
into a different dateformat.
Solution
Use DateFormat
class from intl
package
Examples:
final date=DateTime.parse('1996-07-10');
print(DateFormat('yMd').format(date)); // -> 7/10/1996
print(DateFormat.yMMMMd('en_US').format(date)); // -> July 10, 1996
Answered By - Luis Utrera
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.