Dear all,
I have a problem. I want to subtract two dates use JavaScript.
First date source is from SQL database, I format it use ASP.Net code to "yyyy-MM-dd"
without time and save it into TxtDate.
The second date is from current date.
I want subtract those two dates without entering time of those dates.
The current date currently still has complete date format; "Fri Aug 22 10:06:38 UTC+0700 2008".
So how do I format that current date to "yyyy-MM-dd" format ?
<script LANGUAGE="JavaScript">
var b;
b = 0;
function countDown()
{
var id;
var now = new Date();
var lastUpdate = new Date(form1.TxtDate.value);
var days = Math.floor(((lastUpdate - now) / (60*60*24)) / 1000);
if(days==1)
{
form1.TxtDays.value = "Your password will expire in " + days + " day !!!";
}
else
if(days > 1 && days <= 10)
{
form1.TxtDays.value = "Your password will expire in " + days + " days !!!";
}
else
{
form1.TxtDays.value = "";
clearTimeout(id);
}
if(b==0)
{
b = 1;
}
else
{
b = 0;
form1.TxtDays.value = "";
}
id = window.setTimeout("countDown();",500);
}
</script>