safir.datetime.current_datetime(*, microseconds=False)

Construct a datetime for the current time.

It’s easy to forget to force all datetime objects to be time zone aware. This function forces UTC for all objects.

Databases do not always store microseconds in time fields, and having some dates with microseconds and others without them can lead to bugs, so by default it suppresses the microseconds.


microseconds (bool, default: False) – Whether to include microseconds. Consider setting this to True when getting timestamps for error reporting, since granular timestamps can help in understanding sequencing.


The current time forced to UTC and optionally with the microseconds field zeroed.

Return type: