You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
696 B
Dart
25 lines
696 B
Dart
import 'package:intl/intl.dart';
|
|
|
|
extension DateTimeReadableFormat1 on DateTime {
|
|
// Convert DateTime to the format "12 Feb, 2025 at 12:30pm"
|
|
String toReadableFormat1() {
|
|
final DateFormat formatter = DateFormat("d MMM, yyyy 'at' h:mma");
|
|
return formatter.format(this);
|
|
}
|
|
}
|
|
|
|
extension DateTimeReadableFormat2 on DateTime {
|
|
// Convert DateTime to the format "2025-02-12 12:30:00"
|
|
String toReadableFormat2() {
|
|
final DateFormat formatter = DateFormat("yyyy-MM-dd HH:mm:ss");
|
|
return formatter.format(this);
|
|
}
|
|
}
|
|
|
|
extension DateTimeExtension on String {
|
|
DateTime toDateTime() {
|
|
// Parse the string using the DateTime.parse method
|
|
return DateTime.parse(this);
|
|
}
|
|
}
|