Click to See Complete Forum and Search --> : Javascript current date + tomorrow's date


rosenzl
03-09-2003, 09:32 AM
I have a email form page that uses the following routine to populate a dropdown box. I need to access either the current date or tomorrow's date in my routine that sends me a cdonts email. How can I access the selected or visible date? See www.emailfoodorder.com/emaildemoform2.asp

Thanks

<Td align="left">

<script language="JavaScript"><!--
var now = new Date();
now = new Date(now.getFullYear(),now.getMonth(),now.getDate(),0,0,0); // midnight

var text = '<form><select>';
for (i=0; i<2; i++) {
var theDay = new Date(now.getTime()+(i*24*60*60*1000));
text += '\n<option> ' + (theDay.getMonth()+1) + '/' + theDay.getDate() + '/' + theDay.getFullYear();

}
text += '</select></form>';
document.write(text);
//--></script>
</td>

rosenzl
03-09-2003, 10:26 AM
Ok Dave, here is the real problem. See www.emailfoodorder.com/emaildemoform.asp I realize that at midnight local time in NY the date is not changing. My host is in the mountain time zone. The date does not change until 2:00AM. I need it to change at midnight local time for everyone's locale. Apparently, I am getting the date based on my host's server time. The routine I am using to get the date is:

<%
dim todaydate, tomdate
todaydate = formatdatetime(DATE())
tomdate = dateadd("d", 1, todaydate)
%>

This is my dropdown code:

<!--webbot bot="Validation" s-display-name="Choose" b-disallow-first-item="TRUE" --><Select Name="thedates">
<option name="-choose-" value="-choose-" <% if thedates = "-choose-" then response.write "selected" end if%>>-choose-</option>
<option name="Pickup" value="<%=todaydate%>" <% if thedates = " & todaydate &" then response.write "selected" end if %>><%= todaydate %></option>
<option name="Delivery" value="<%=tomdate%>" <% if thedates = " & tomdate &" then response.write "selected" end if %>><%= tomdate %></option>

</Select>

I have a validation routine that works fine, but the date is not changing at the correct time. Is there a way to use a local date routine where I can incorporate it into the above?

Thanks Dave

rosenzl
03-09-2003, 02:45 PM
Dave, If I did what you said then everyone in the central time zone would be off by an hour. Everyone in the mountain timezone would be off, etc. What's funny is that the javascript routine I first told you of works off the local clients pc, but I don't know how to get the dates into my cdonts email (outside of the javascript routine). That's my problem.

How could I make the javascript date routine a function and make it pass the 2 dates back to me so then It can be used as needed?

Thanks

khaki
03-10-2003, 06:26 PM
Hi Rosenzl...

I had this issue once as well.
I remember having to use:
getTimezoneOffset
(something like that) to compare the visitors clock to GMT, and then creating conditions for adjusting +/- hours.

I have the javascript function that I used for that on my laptop (which I left at work), so I will look for it tomorrow and get back to you with it.

Sorry to put you off till then.... but help is on the way!

with knowledge spread-out over many hard-drives...
k

khaki
03-12-2003, 09:30 PM
Actually, I hadn't already seen it Dave. But I'm so put-off by some of the demanding and ungrateful attitudes that some people display here, that sometimes I just resent the idea of helping some people at all.

Personally it burns-me-out to find the same question posted all over the place - as though some people's questions are more important than the time that is taken by those are willing to take the time to answer them.

I know that I don't have the track-record and experience that many of you have in answering questions here, but I do understand that help such as this should be appreciated and respected.

I apologize for opinionating here... but not for the opinion.
k