Jump to content

javascript Unix Time


StirCrazy

Recommended Posts

I'm trying to get unix time based on data inputted into a drop down menu: example code below:-

 

 

<select id="dateselector" value="day" class="datedropdown">
<option onChange="updateDate();" value="01" name="inDay" >1</option>
<option onChange="updateDate();" value="02" name="inDay" >2</option>
<option onChange="updateDate();" value="03" name="inDay" >3</option>
<option onChange="updateDate();" value="04" name="inDay" >4</option>
...
<select id="dateselector" value="month" class="datedropdown">
<option onChange="updateDate();" value="01" name="inMon" >January</option>
<option onChange="updateDate();" value="02" name="inMon" >February</option>
<option onChange="updateDate();" value="03" name="inMon" >March</option>
...
<select id="dateselector" value="year" class="datedropdown">
<option onChange="updateDate();" value="06" name="inYear" >2006</option>
<option onChange="updateDate();" value="07" name="inYear" >2007</option>
...

 

 

I have no idea how to get the updateDate() function to output unix time into 'var timestamp' as i have very little experience with .js

 

 

I'm guessing it looks a little like:-

 

function updateDate() {

    var timestamp = new Date(Date.UTC(document.getElementsByName("inYear").value,
          (stripLeadingZeroes(document.getElementsByName("inMon").value)-1),
           stripLeadingZeroes(document.getElementsByName("inDay").value),
           0, 0, 0));
           timestamp=timestamp.getTime()/1000.0;
	   updateText();
}

 

(updateText(); then updates a text area)

 

Any help to with the correct syntax would be great.

 

Thanks in advance  :)

 

S.C>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.