by @kodeazy
flutter How to convert current timestamp into date in dart file?
- In this blog we will be discussing on how to get
time
fromtimestamp
in flutter. - To get the current time from timestamp we use
DateTime.fromMillisecondsSinceEpoch
method. -
Below is the sample example of printing the current time from timestamp using flutter.
import 'package:flutter/material.dart'; void main() { var timestamp = DateTime.now().millisecondsSinceEpoch; print(DateTime.fromMillisecondsSinceEpoch(timestamp)); }
Output
2022-08-15 16:29:47.093