I have a locally hosted (on my machine) simple HTML page that we use in the office for tracking work orders. I made it as simple as possible. One dynamic element I need is to display the 5 digit Julian date inside of an IFRAME.
The format needs to be (ex): 24043
24 for the last two of the year, and 043 being the 43rd day of this calendar year (February 12, 2024).
I have tried multiple different posts, and guides to get this working, but none of them thus far has worked correctly, or most times, at all.
Here is the code I have in my HEAD at the moment:
<script type="text/javascript">
document.getElementById('txt').julianDate;
//set an array with day counts for all months
var dayCount = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
function convertDate(str) {
//convert passed string to date object
var dte = new Date(str);
//initialize date variable
var julianDate = 0;
//add days for previous months
for (i = 0; i < dte.getMonth(); i++) {
julianDate += dayCount[i];
}
//add days of the current month
julianDate += dte.getDate();
//check for leap year
if (dte.getFullYear() % 4 == 0 && dte.getMonth() > 1) {
julianDate++;
}
//alert("Julian Date: " + julianDate);
//var jdate = julianDate
//return julianDate;
document.getElementById("JulianDate").innerHTML = julianDate2
}
</script>
And in the body (as a test) I have this:
<h1>"The value for number is: " <span id="JulianDate2"></span></h1>
My current output is:
“The value for number is: “
with no value being put out. I’m not a programming whiz by any means, so I have to look most of this up, and work my way though it the best I can.