from datetime import datetime
from typing import Optional


def get_epoch_time(time_as_str: Optional[str] = None,
                   fmt: str = '%d-%m-%Y %H:%M:%S.%f') -> int:
    """
    >>> get_epoch_time('04-09-2020 17:13:40.162')
    1599239620162
    """
    fmt_time = datetime.now() if time_as_str is None else datetime.strptime(
        time_as_str, fmt)
    epoch = datetime.utcfromtimestamp(0)
    return int((fmt_time - epoch).total_seconds() * 1000)