Samet
Samet

Reputation: 73

Convert String Date to DateTime in flutter

enter image description here

How to convert RequireDate(String) to DateTime ?

Upvotes: 0

Views: 1707

Answers (2)

Tirth Patel
Tirth Patel

Reputation: 5756

You could use intl for this. Based on the format of RequiredDate, design a DateFormat and call parse on the input.

import 'package:intl/intl.dart';

void main() {
  print(DateFormat("dd/MMM/y").parse("31/Oct/2022"));
}

You could try this code on https://dartpad.dev as well, I tinkered it on it to design the solution.

enter image description here

Upvotes: 2

pythonGo
pythonGo

Reputation: 173

Use a datetime parse DateTime RequireDate;

RequireDate: DateTime.parse(RequireDate),

Upvotes: 0

Related Questions