[Javascript] ARGH! Help with Dates!
Dave Stoltz
dstoltz at shh.org
Fri Jan 2 13:12:40 CST 2004
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/ce6c3e9b/attachment.html>
More information about the Javascript
mailing list