Click to See Complete Forum and Search --> : System Date and time


priyam
08-27-2008, 03:08 AM
hi
Please tell me how can i capture system date and time and display it on my HTML page
I am using ASP and VBScript
If i use date() function it captures server date.
I would be really greatful if anybody could help.
Please give me the code block for the above if possible.

Thanx

eCat
08-27-2008, 02:57 PM
Since ASP is a server-side scripting process, the time or date will always be the time or date of the server - not the local time. In order to get the local time, you should use javascript (client-side).

For the date:

<script type="text/javascript">
<!--
var currentTime = new Date()
var month = currentTime.getMonth() + 1
var day = currentTime.getDate()
var year = currentTime.getFullYear()
document.write(month + "/" + day + "/" + year)
//-->
</script>

For the time:

<script type="text/javascript">
<!--
var currentTime = new Date()
var hours = currentTime.getHours()
var minutes = currentTime.getMinutes()
if (minutes < 10)
minutes = "0" + minutes
document.write(hours + ":" + minutes + " ")
if(hours > 11){
document.write("PM")
} else {
document.write("AM")
}
//-->
</script>

eCat