I need to do a web-form. It must content a date filter, i.e. some items must be shown if its are created between one date and other date. My form:
<form id="tweetshow" method="post" action="" >
<p>
Enter user_id: <input type="text" name="user_id" />
</p>
<p>
Enter user last tweets amount: <input type="text" name="last_tweets_amount" />
</p>
<p>
From date: <input type="date" name = "from_date" step=7 min=2014-09-08>
</p>
<p>
To date: <input type="date" name = "to_date" step=7 min=2014-09-08>
</p>
<p>
<input type="button" value="Submit" onClick="ShowTweets()"/>
</p>
</form>
This is my java-script, which proccesses it:
<script>
var test = document.forms['tweetshow'].to_date.value;
...
success:function(response)
{
...
if((item.created_at <= test))
{
$("<article>", { id: item.id })
.append($header, $text, $details)
.appendTo("#tweets");
alert(test);
}
}
...
</script>
The variable "item.created_at" consists a date, which is built, for example, how this pattern: "Sun Oct 19 11:45:28 +0000 2014", but the date, which enters in form(it consists in variable "test"), builds as this pattern: "2014-10-19". How to compare the dates correctly?