Fix bug of timestamp calculation