This is my time.js file:
function timeSince(date) {
var seconds = Math.floor((new Date() - date) / 1000);
var interval = Math.floor(seconds / 31536000);
var timesince = "";
if (interval > 1) {
timesince = interval + " years";
}
interval = Math.floor(seconds / 2592000);
if (interval > 1) {
timesince = interval + " months";
}
interval = Math.floor(seconds / 86400);
if (interval > 1) {
timesince = interval + " days";
}
interval = Math.floor(seconds / 3600);
if (interval > 1) {
timesince = interval + " hours";
}
interval = Math.floor(seconds / 60);
if (interval > 1) {
timesince = interval + " minutes";
}
timesince = Math.floor(seconds) + " seconds";
document.write(timesince)
}
and this is my html snippet:
<html>
<head>
<title>A Simple Blog</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script type="text/javascript" src="/static/js/time.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">
<link rel="stylesheet" href="/static/css/bootstrap.min.css">
<link rel="stylesheet" href="/static/css/style.css">
</head>
<body>
<div class="post-heading">
<h1>{{post.title}}</h1>
<br><br>
<!-- <h2 class="subheading"></h2> -->
<span class="meta">Posted by <a href="#">{{post.author.username}}</a> ago.</span>
<script>
timeSince({{post.created}});
</script>
</div>
I can't seem to find out why I keep getting this error. I'm using Google app engine with python and jinja2 to build this app but I'm guessing it's the format of my js code that is causing this problem perhaps? Any advice would be appreciated.