datetime property
Expression<String>
get
datetime
Formats this datetime in the format year-month-day hour:minute:second
.
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<String> get datetime {
return _DependingOnDateTimeExpression.generate((datesAsText) {
return FunctionCallExpression('DATETIME',
[this, if (!datesAsText) const DateTimeModifier._unixEpoch()]);
});
}