Created
March 11, 2023 18:04
-
-
Save witchfindertr/b7c5596eaed5693a22f9e9df7344ecfb to your computer and use it in GitHub Desktop.
flutter zaman
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| publishtime: DateTime.now().subtract(Duration(days: 10)); | |
| _getTime() { | |
| String time; | |
| DateTime now = DateTime.now(); | |
| Duration difference = now.difference(publishtime); | |
| if (difference.inHours > 24) { | |
| var format = DateFormat("dd.MM.yyyy"); | |
| time = format.format(publishtime); | |
| } else { | |
| time = difference.inHours.toString().replaceAll('-', '') + " hours ago"; | |
| } | |
| return time; | |
| } | |
| DateTime dt1 = DateTime.parse("2021-12-23 11:47:00"); | |
| DateTime dt2 = DateTime.parse("2018-09-12 10:57:00"); | |
| Duration diff = dt1.difference(dt2); | |
| print(diff.inDays); | |
| //output (in days): 1198 | |
| print(diff.inHours); | |
| //output (in hours): 28752 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment