I have tried like this
<script type="text/javascript">
var date2=02/09/2009;
var date1=03/12/2009;
var diff = date1.getDate()-date2.getDate();
alert (diff);
</script>
but it's not working, is that reason getDate
will work only for Date
?
How to find the difference between these two dates? Am I not able use this function, because I am adding javascript in salesforce CRM apex pages?
Edit 1 : infact this too not working
<script type="text/javascript">
var date2= new Date ("02/09/2009");
var date1= new Date ("04/09/2009");
var diff = date1.getDate()-date2.getDate();
alert (diff);
</script>
Edit 2 : its not working too ...
<script type="text/javascript">
var date2= "02/09/2009";
var date1= "04/09/2009";
var diff2 = new Date(Date.parse("03/12/2009")-
Date.parse("02/09/2009")).toLocaleDateString();
// var new_date = new Date (1970, 01, 01); // var diff3 = diff2.getDate(); alert (diff2);
</script>