cGetFormattedDate method
Converts the DateTime instance into a formatted date string.
Optionally, you can provide a custom format
string to specify the
desired date format. If format
is not provided, the default format
'dd/MM/yyyy' will be used.
Example:
final date = DateTime.now();
final formattedDate = date.cGetFormattedDate(format: 'MM-dd-yyyy');
print(formattedDate); // Output: 09-13-2023
Implementation
String cGetFormattedDate({String? format}) {
try {
return DateFormat(format ?? 'dd/MM/yyyy').format(this);
} catch (e) {
return (this).toString();
}
}