truncate method

  1. @useResult
ZonedDateTime truncate({
  1. required TemporalUnit to,
})

Returns a copy of this truncated to the TemporalUnit.

final date = ZonedDateTime('Asia/Singapore', 2023, 4, 15);
date.truncate(to: DateUnit.months); // 2023-04-01T00:00+08:00[Asia/Singapore]

Implementation

@useResult ZonedDateTime truncate({required TemporalUnit to}) => ZonedDateTime._convert(timezone, _native.truncate(to: to));