import time


def create_iv_epoch_rounded(period_length_seconds):
    """
    Creates an 8-byte array of the time for the IV
    :param input period_length_seconds: MTD period length in  seconds
    :return: 8-bytte array of the time
    """

    epoch = time.time()

    # Floor-Rounding the current epoch time to the nearest epoch
    # that is a multiple of our period length.
    # (e.g. if period is 1 hour, and we launched this at
    #     01:33:11 UTC on 1 January 1970,
    # Epoch will be Floor-Rounded to exact multiples of one hour, in this case
    #     01:00:00 UTC on 1 January 1970)

    epoch_rounded = epoch - (epoch % period_length_seconds)
    return epoch_rounded.to_bytes(8, "little")