toDate property

DateTime get toDate

Attempts to parse the string into a DateTime object. Returns null if the parsing fails.

Example:

print('2023-01-01'.toDate); // Output: Instance of 'DateTime' for 2023-01-01
print('1643723400'.toDate); // Output: Instance of 'DateTime' for 2022-02-01
print('abc'.toDate); // Output: Instance of 'DateTime' for 1970-01-01 00:00:00 GMT

Implementation

DateTime get toDate => toDateTime;