Answers for "flutter datetime.now only time"

3

how to display current date time in flutter

DateTime dateToday = DateTime(DateTime.now().year, DateTime.now().month, DateTime.now().day) ;
Posted by: Guest on January-03-2021
0

flutter datetime.now only time

import 'package:intl/intl.dart';

DateTime now = DateTime.now();
String formattedTime = DateFormat.Hms().format(now);
print(formattedTime);
Posted by: Guest on June-03-2021
0

how to show date only in flutter

import 'package:flutter/material.dart';
import 'package:intl/intl.dart';

void main() => runApp(App());

class App extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Current Date Example',
      home: DateExample(),
    );
  }
}


class DateExample extends StatelessWidget {
  const DateExample({Key key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(child: Text(DateFormat("yyyy-MM-dd").format(DateTime.now()))),
    );
  }
}
Posted by: Guest on January-03-2021

Browse Popular Code Answers by Language