year property

Expression<int> get year

Extracts the year from this datetime expression.

Even if the date time stored was in a local timezone, this format returns the formatted value in UTC. For example, if your local timezone has the UTC offset +02:00 and you're inserting a (local) DateTime value at 12:34, running the hour getter on this value would return 10, since the datetime is at 10:34 in UTC.

To make this function return a value formatted as a local timestamp, you can use modify with a DateTimeModifier.localTime before invoking it, e.g.

 Variable(DateTime.now()).modify(DateTimeModifier.localTime()).hour

Implementation

Expression<int> get year => _StrftimeSingleFieldExpression('%Y', this);