This is my first post, sorry if it's wrong. I could not find a bbcode like this anywhere.
I'm not sure what to call this, but this bbcode converts a Unix epoch timestamp to human readable format. You can swap around the format if you like, I'm just American.
BBCode:HTML replacement:Help line:
I'm not sure what to call this, but this bbcode converts a Unix epoch timestamp to human readable format. You can swap around the format if you like, I'm just American.
BBCode:
Code:
[epoch]{TEXT}[/epoch]
Code:
<epoch>{TEXT}</epoch><script>document.addEventListener("DOMContentLoaded", function() { // Function to convert epoch to human-readable format function convertEpochToHumanReadable(epoch) { let date = new Date(epoch * 1000); let year = date.getFullYear(); let month = ('0' + (date.getMonth() + 1)).slice(-2); let day = ('0' + date.getDate()).slice(-2); let hours = ('0' + date.getHours()).slice(-2); let minutes = ('0' + date.getMinutes()).slice(-2); let seconds = ('0' + date.getSeconds()).slice(-2); return `${month}-${day}-${year} ${hours}:${minutes}`; } // Find all elements with the custom BBCode document.querySelectorAll('epoch').forEach(function(element) { let epochTimestamp = parseInt(element.innerText); if (!isNaN(epochTimestamp)) { element.innerText = convertEpochToHumanReadable(epochTimestamp); } });});</script>
Code:
replace {TEXT} with a unix timestamp such as one generated from https://www.epochconverter.com/Time is displayed MM/DD/YYY HH:MM
Statistics: Posted by defvenom — Thu Jul 11, 2024 1:52 am