Click to See Complete Forum and Search --> : Want a calendar and date component to use in my jsp


prabhukm
07-10-2003, 04:56 AM
Dear All,
I am developing an ui. In that ui i want to use a date and time component. That component should produce the output like July 10 2003, 03:34:03 PM. So please someone help me to write a component. The language i am using is JSP, JavaScript and HTML.

Thanks in advance.

Bye,
Prabhu:)

jalarie
07-10-2003, 07:50 AM
Now=new Date();
Now_Y=Now.getYear();
Now_M=Now.getMonth();
Now_D=Now.getDate();
Now_H=Now.getHours();
Now_N=Now.getMinutes();
Now_S=Now.getSeconds();
if (Now_Y < 70) { Now_Y=Now_Y*1+2000; }
if (Now_Y < 1900) { Now_Y=Now_Y*1+1900; }
if (Now_H < 10) { Now_H='0'+Now_H; }
if (Now_N < 10) { Now_N='0'+Now_N; }
if (Now_S < 10) { Now_S='0'+Now_S; }
Month_Names=new Array('January','February',
'March','April','May','June','July','August',
'September','October','November','December');
if (Now_H < 12) {
Now_A='AM';
} else {
if (Now_H == 12) {
Now_A='PM';
} else {
Now_A='PM';
Now_H=Now_H-12;
}
}
if (Now_H == 0) {
Now_H='12';
}
Display =Month_Names[Now_M]+' '+Now_D+' '+Now_Y;
Display+=', '+Now_H+':'+Now_N+':'+Now_S+' '+Now_A;
alert(Display);

prabhukm
07-10-2003, 08:36 AM
Dear jalarie,
Thanks for your help. Actually my requirement is to display the Date and time component in an UI, from there the user can select the date and time. This will acts as a criteria to show the records in an view. For example, in an mailing group want to view the mails received from July 10 2003, 10:30:00 AM to July 11 2003, 10:30:00 PM. So we have to create a view to show those records. So my feeling is the user should select those values from a component and we should not pain him to type all those things in an text box. I think this may give you a clear picture about my requirement.
Once again thanks for your help.

Bye,
Prabhu

Khalid Ali
07-10-2003, 09:10 AM
I think something like this is what you are looking for..

http://68.145.35.86/temp/milli/calendar/Calendar.html

prabhukm
07-10-2003, 09:18 AM
Khalid,
Thanks, ya exactly right. but in that i want a time field also. Such that we can select the Hr:Min:Sec. Could you please help me to find a component with source.

Bye,
Prabhu

Khalid Ali
07-10-2003, 09:37 AM
You can add a text field next to the date field (in the html- body section of thepage)

Here use this ..

<script type="text/javascript">
<!--
Date.prototype.LongTime = function(){
function formatNum(num){
return (num<10)?"0"+num:num;
}
var dateStr = formatNum(this.getHours())+":"+formatNum(this.getMinutes())+":"+formatNum(this.getSeconds());
return dateStr;
}
function Process(){
var frm = document.getElementById("form1");
var len = frm.length;
}
function LoadTime(){

var date = new Date();
document.getElementById("time").value = date.LongTime();
}
//-->
</script>
</head>

<body class="body" onload = "LoadTime()">
<form id="form1" action="" onsubmit="">
<input type="text" id="time"/><a href="javascript:void(0);" onclick="LoadTime()">Get Time</a>
</form>