I'd like to add a counter to my website which counts in days. However I'd also like to add a button where this can be reset back to 0.
After searching I found the below code, and all is needed now is the button for it. I'm no Javascript expert so any help would be great.
I used this code to create the counter:
<script type="text/javascript">
//Set the two dates
var startdate=new Date(2013, 11, 16) //Month is 0-11 in JavaScript
today=new Date()
//Get 1 day in milliseconds
var one_day=1000*60*60*24
//Calculate difference btw the two dates, and convert to days
document.write(Math.ceil((today.getTime()-startdate.getTime())/(one_day))+
" days since your last drink!")
</script>
Is there a way I can include a button to reset the start date to the current date (for example if pressed today it would change from 16th of December 2013 to the 19th of December 2013)
Does anyone have any idea how I would do this? I'm fairly new to javascript so just learning the ropes.
Thanks
Gary