toTimestamp method

int toTimestamp(
  1. TimeUnit unit
)

Format DateTime to timestamp.

Example:

DateTime(2022, 9, 1, 1, 23, 45, 123).toTimestamp(TimeUnit.milliseconds); // 1661966625123
DateTime(2022, 9, 1, 1, 23, 45).toTimestamp(TimeUnit.seconds); // 1661966625

Implementation

int toTimestamp(TimeUnit unit) => unit.formatTimestamp(this);