首页 > 解决方案 > Flutter Firstore 时间戳现在/当前日期

问题描述

以下是我使用并发现很方便的所有 Firebase 时间戳方法。

标签: fluttergoogle-cloud-firestoretimestamp

解决方案


如何获取 Firestore 时间戳(今天日期)

Timestamp timestampDate = Timestamp.now();

如何从日期时间设置时间戳

DateTime someDate = DateTime.now();
Timestamp timestampDate =  Timestamp.fromDate(DateTime(someDate.year, someDate.month, someDate.day))

如何从时间戳中获取日期对象

DateTime dateTime = timestampDate.toDate();

推荐阅读