set timestamp before encoding