I've a script and I want to use another sentence instead of document.write()
as you can see at the last line
document.write(convertTimestamp("<data:post.timestamp/>"));
<script>
function convertTimestamp(timestamp) {
var currentTime = new Date();
var convertedTimestamp = new Date(timestamp);
var offset = -new Date().getTimezoneOffset();
convertedTimestamp = new Date(convertedTimestamp.getTime() + offset * 60 * 1000);
var timeDifference = currentTime - convertedTimestamp;
var seconds = Math.floor(timeDifference / 1000);
var minutes = Math.floor(seconds / 60);
var hours = Math.floor(minutes / 60);
if (seconds < 60) {
return seconds + ' seconds39;;
} else if (minutes < 60) {
return minutes + ' mins ';
} else (hours < 24) {
return hours + ' hours';
}
}
document.write(convertTimestamp("<data:post.timestamp/>"));
</script>
Can I use other words instead of document.write?
I saw a recommendation to use
document.body.append
or
document.body.innerHTML
but I don't know how to apply it on my code.