Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Displaying Database Server time in JSP

843838Sep 19 2006
Hi
Is there any query in SQL which will retrive DataBase date and
time.The time should be dynamic it should increase as the database time
increases.I have done similar thing for application Server time in
JavaScript.

I tried
select sysdste from dual

in SQL it gives the following Output

2006-09-18

.But in my case time should increase.

fr Examle

18-Sep-2006 06:40:15 PM (In this the seconds column should increase as time
increases).

I have done similar thing for Application server(In my case Jboss).Using an
.shtml file(ie.SSI) file.Thats given below

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

<html>
<body>
<script type="text/javascript">
// Current Server Time script (SSI or PHP)- By JavaScriptKit.com
(http://www.javascriptkit.com)
// For this and over 400+ free scripts, visit JavaScript Kit-
http://www.javascriptkit.com/
// This notice must stay intact for use.
//Depending on whether your page supports SSI (.shtml) or PHP (.php),
UNCOMMENT the line below your page supports and COMMENT the one it does not:
//Default is that SSI method is uncommented, and PHP is commented:
var currenttime = '<!--#config timefmt="%B %d, %Y %H:%M:%S"--><!--#echo
var="DATE_LOCAL" -->' //SSI method of getting server date
//var currenttime = '<? print date("F d, Y H:i:s", time())?>' //PHP method
of getting server date
///////////Stop editting here/////////////////////////////////
var montharray=new
Array("January","February","March","April","May","June","July","August","September","October","November","December")
var serverdate=new Date(currenttime)
function padlength(what){
var output=(what.toString().length==1)? "0"+what : what
return output
}
function displaytime(){
serverdate.setSeconds(serverdate.getSeconds()+1)
var datestring=montharray[serverdate.getMonth()]+"
"+padlength(serverdate.getDate())+", "+serverdate.getFullYear()
var
timestring=padlength(serverdate.getHours())+":"+padlength(serverdate.getMinutes())+":"+padlength(serverdate.getSeconds())
document.getElementById("servertime").innerHTML=datestring+" "+timestring
}
window.onload=function(){
setInterval("displaytime()", 1000)
}
</script>
Current Server Time:<span id="servertime"></span>
</body>
</html>


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

18-Sep-2006 06:40:15 PM (This is the output that i got).

can u help me in this regard.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 17 2006
Added on Sep 19 2006
0 comments
184 views