DateTime

class chepy.modules.datetimemodule.DateTime(*data)
from_unix_timestamp(format: str = '%c', utc: bool = False) DateTimeT

Convert UNIX timestamp to datetime

Parameters
  • format – Format to use for datetime.strftime()

  • utc – Whether to use UTC or local timezone

Returns

The Chepy object.

Return type

Chepy

Examples

>>> Chepy("1573426649").from_unix_timestamp()
"Sun Nov 10 17:57:29 2019"
to_unix_timestamp() DateTimeT

Convert datetime string to unix ts

The format for the string is %a %b %d %H:%M:%S %Y, which is equivalent to %c from datatime.

Returns

The Chepy object.

Return type

Chepy

Examples

>>> Chepy("Sun Nov 10 17:57:29 2019").to_unix_timestamp()
"1573426649"