i need to remove (-,:,space,etc from my DateTime || Flutter ||


”’final Time = uniqueid + DateTime.now().toString() + DateTime.now().millisecond.toString();”’

and get Time =uniqueid2022-01-24 16:42:03 .901280901
need Time =uniqueid20220124164203901280901


we can use this method to get exact result
first add plugin intl

flutter pub add intl

then import

import 'package:intl/intl.dart';

then use this where you need the formatted date

final DateTime now = DateTime.now();
final DateFormat formatter = DateFormat('yyyyMMddkkmms');
final String formatted = formatter.format(now);
final Time = unique + formatted + DateTime.now().millisecondsSinceEpoch.toString();

Answered By – Shafi Asharaf

Answer Checked By – Mildred Charles (FlutterFixes Admin)

Leave a Reply

Your email address will not be published. Required fields are marked *