sciris.sc_datetime.getdate

getdate(obj=None, astype='str', dateformat=None)[source]

Alias for converting a date object to a formatted string.

See also sc.now().

Parameters
  • obj (datetime) – the datetime object to convert

  • astype (str) – what to return; choices are “str” (default), “dateobj”, “float” (full timestamp), “int” (timestamp to second precision)

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

Examples:

sc.getdate() # Returns a string for the current date
sc.getdate(astype='float') # Convert today's time to a timestamp