Displaying the date in a form field

Hi everyone,

I am using the follow code to display the date in a form field, but my date is stuck as 20100106, when my computer shows 20100107. What’s wrong?

<script language="javascript">
        function setIt() {
                var d = new Date(2010,01,06);
                s = d.getFullYear();
                s += ((d.getMonth())>9)?(d.getMonth()):("0"+(d.getMonth()));
                s += ((d.getDate())>9)?(d.getDate()):("0"+(d.getDate()));
                document.getElementById("CycleDate").value = s;
		document.getElementById("CycleDate2").value = s;
        }
</script>

Well, you’re setting the date to 2010-01-06, so of course that will show up. :slight_smile:

To use the current date (on the client computer), do this,

var d = new Date();

Okay I removed the 2010, 01, 06 from the new date variable. Now I get the correct year and day, but my month is 00 for January. How would I change that?

Never mind! I figured it out.