timeIntervalSinceReferenceDate
は、iOSのFoundationフレームワークで提供されるメソッドで、2001年1月1日午前0時(UTC)から現在までの秒数を表します。Dartで同じ機能を実現するには、以下のようにして現在の日時を取得し、それを2001年1月1日午前0時(UTC)からの経過時間に変換します。
DateTime now = DateTime.now().toUtc(); DateTime referenceDate = DateTime.utc(2001, 1, 1, 0, 0, 0); double timeInterval = now.difference(referenceDate).inSeconds.toDouble();
これで、timeIntervalSinceReferenceDate
に相当する値が timeInterval
に格納されます。この値は、1970年1月1日午前0時(UTC)からの経過秒数を表すUNIXタイムスタンプとは異なることに注意してください。