[Javascript] ARGH! Help with Dates!

jsWalter jsWalter at torres.ws
Fri Jan 2 20:23:25 CST 2004


web.torres.ws./dev/javascript

I have a pretty complete DATE Class Object there.

Take it, play with it. See if it helps.

Walter

  -----Original Message-----
  From: javascript-bounces at LaTech.edu
[mailto:javascript-bounces at LaTech.edu]On Behalf Of Dave Stoltz
  Sent: Friday, January 02, 2004 1:13 PM
  To: '[JavaScript List]'
  Subject: [Javascript] ARGH! Help with Dates!


  I am trying desperately to get the date in Javascript in EXACTLY this
format: 1/4/2004 5:45 PM

  This seems painfully difficult....I have the following 2 functions
working, except the month comes back as 0 all the time.
  If the dropdown box called "Priority" is "Normal", I want to add 2 days to
the current date/time, and if Priority is "Emergency" I want to add 1 day to
the current date/time.

  Here are my functions, why is the month coming back as 0 !!!!???

  Thanks for any help!

  <script language="javascript">
  <!--
  function addDays(myDate,days) {
       cDate = new Date(myDate.getTime() + days*24*60*60*1000);
       dy = cDate.getDate();
       mn = cDate.getMonth();
       y = cDate.getYear();
       h = cDate.getHours();
       m = cDate.getMinutes();
       s = cDate.getSeconds();
       nDate = mn + "/" + dy + "/" + y + " " + h + ":" + m + ":" + s;
       return nDate;
  }
  function setdueby(){
       var1 = form1.Priority.value;
       if(var1=='Normal'){
       var2 = (addDays(new Date(),2));
       form1.dueby.value=var2;
       }
       if(var1=='Emergency'){
       var3 = (addDays(new Date(),1));
       form1.dueby.value=var3;
   }}
  -->
  </script>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.evolt.org/pipermail/javascript/attachments/20040102/ac5f563a/attachment.htm>


More information about the Javascript mailing list