DateTimeNowToEpoch

Returns the current datetime as an epoch value for use in timestamp comparisons.

python · Community Common Scripts

Details

IDDateTimeNowToEpoch
Languagepython
From Version6.9.0
Docker Imagedemisto/python3:3.12.13.10116658

README

Converts the current datetime to an epoch value for timestamp comparison operations

import demistomock as demisto  # noqa: F401
from CommonServerPython import *  # noqa: F401


def retrieve_epoch() -> int:
    # Return current epoch value for datetime.now
    return int(time.time())


def main():  # pragma: no cover
    epoch = retrieve_epoch()
    demisto.setContext("DateTimeNowEpoch", epoch)
    return_results(epoch)


if __name__ in ("__main__", "__builtin__", "builtins"):
    main()