I'm trying to create a dynamic iframe that loads a page that is named after the date in yyyy-mm-dd format with the addition of +AM and +PM added at the end. Example: https://example.com/display/stuff/2016-10-02+AM
This is what I have so far.. I'm not getting any syntax errors but it won't render.
<!DOCTYPE html>
<html>
<body>
<script type="text/javascript">
var today = new Date();
var dd = today.getDate;
var mm = today.getMonth;
var yyyy = today.getFullYear;
var h = h > 12 ? h - 12 + 'PM' : h + 'AM';
if (dd < 10) {
dd = '0' + dd;
}
if (mm < 10) {
mm = '0' + mm;
}
var today = yyyy + '-' + mm + '-' + dd + '+' + h;
</script>
document.body.innerHTML = ('<iframe src="https://example.com/display/stuff/'today'/"'</iframe>')
</body>
</html>
See Question&Answers more detail:os