now(astype='dateobj', timezone=None, utc=False, tostring=False, dateformat=None)[source]#

Get the current time as a datetime object, optionally in UTC time. is similar to sc.getdate(), but returns a datetime object by default, while sc.getdate() returns a string by default.

  • astype (str) – what to return; choices are “dateobj”, “str”, “float”; see sc.getdate() for more

  • timezone (str) – the timezone to set the itme to

  • utc (bool) – whether the time is specified in UTC time

  • dateformat (str) – if astype is 'str', use this output format

Examples: # Return current local time, e.g. 2019-03-14 15:09:26'US/Pacific') # Return the time now in a specific timezone # Return the time in UTC'str') # Return the current time as a string instead of a date object; use 'int' for seconds # Backwards-compatible alias for astype='str''%Y-%b-%d') # Return a different date format

New in version 1.3.0: made “astype” the first argument; removed “tostring” argument