473,399 Members | 3,401 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Setting Date Time

Hi all
I think this is in the wrong group but since I don't read others much
or code in java script I was wondering if anyone could help me with
this small problem, as I code mostly in ASP vbscript.

I have the following piece of Javascript client code that displays the
users clock on the browser and updates it every second.

I was wondering is it possible for me to set the time to the SERVER
time via ASP vbscript. and then update this time every second on the
users browser. I want all users to see the time & date of the SERVER
and not thier time/date. I've tried looking at
www.javascriptsource.com and not found anything that might help.

The current code I have is:

function NewTime() {
mDateTime1 = Date().split(" ");
var clockHandle = true; // Dummy init value
clockHandle = GetElement('MyDateTime');
if (clockHandle) {
clockHandle.innerHTML = mDateTime1[1] + " " +
mDateTime1[2] + ", " + mDateTime1[4] + ", " + mDateTime1[3];
}
setTimeout("NewTime()",500);
}

Could anyone modify this so I can set the time for it to start at???

Thanks for any help on this matter.

Al.
Jul 19 '05 #1
7 4880
If you want to get the server's time, just use <%=Time%> wherever you need
it to appear. You can put <%=Time%> in your jscript code if that's where
you need it.

Ray at home

"Harag" <ha***@REMOVETHESECAPITALSsofthome.net> wrote in message
news:89********************************@4ax.com...
Hi all
I think this is in the wrong group but since I don't read others much
or code in java script I was wondering if anyone could help me with
this small problem, as I code mostly in ASP vbscript.

I have the following piece of Javascript client code that displays the
users clock on the browser and updates it every second.

I was wondering is it possible for me to set the time to the SERVER
time via ASP vbscript. and then update this time every second on the
users browser. I want all users to see the time & date of the SERVER
and not thier time/date. I've tried looking at
www.javascriptsource.com and not found anything that might help.

The current code I have is:

function NewTime() {
mDateTime1 = Date().split(" ");
var clockHandle = true; // Dummy init value
clockHandle = GetElement('MyDateTime');
if (clockHandle) {
clockHandle.innerHTML = mDateTime1[1] + " " +
mDateTime1[2] + ", " + mDateTime1[4] + ", " + mDateTime1[3];
}
setTimeout("NewTime()",500);
}

Could anyone modify this so I can set the time for it to start at???

Thanks for any help on this matter.

Al.

Jul 19 '05 #2
Harag wrote on 20 dec 2003 in microsoft.public.inetserver.asp.general:
I think this is in the wrong group but since I don't read others much
or code in java script I was wondering if anyone could help me with
this small problem, as I code mostly in ASP vbscript.

I have the following piece of Javascript client code that displays the
users clock on the browser and updates it every second.


Only coded for IE:

======== times.asp =======

Client timezone corrected server date/time:
<div id=a>Please wait</div>
Client date/time:
<div id=b>Please wait</div>

<script runat=server language=jscript>
gmt=+new Date()
</script>

<script>
var t=+<%=gmt%>
var tOut
function eachSecond(){
tOut=setTimeout('eachSecond()',1000)
a.innerHTML=new Date(t)
b.innerHTML=new Date()
t+=1000
}
eachSecond()
</script>

================

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 19 '05 #3

"Harag" <ha***@REMOVETHESECAPITALSsofthome.net> wrote in message
news:89********************************@4ax.com...
Hi all
I think this is in the wrong group but since I don't read others much
or code in java script I was wondering if anyone could help me with
this small problem, as I code mostly in ASP vbscript.

I have the following piece of Javascript client code that displays the
users clock on the browser and updates it every second.

[remaining post snipped]

I never understood the purpose of putting the users's clock on a webpage. It
always seems like a waste of resources, especially updating every second.
The user already has a clock, why give them another?

Don

Jul 19 '05 #4
Hi

THANKS! for the help, it works great.

I've copied my version below incase anyone is interested.

Al

*********************
<%@ language="VBScript" %>
<% Option Explicit %>
<%
' VBscript!!!
DIM GMT
GMT = year(now) & ", "&month(Now)-1&", "&day(now)&",
"&hour(now)&", "&Minute(Now)&", " & second(now)
%>

<head>
<script language="JavaScript1.2" type="text/javascript">
<!-- Begin
function UserTime()
{
mDateTime1 = Date().split(" ");
var clockHandle = true; // Dummy init value
clockHandle = GetElement('MyDateTime');
if (clockHandle) {
clockHandle.innerHTML = mDateTime1[1] + " " +
mDateTime1[2] + ", " + mDateTime1[4] + ", " + mDateTime1[3];
}
setTimeout("UserTime()", 500);
}
var t=+ new Date(<%=GMT %>)
function ServerTime() {
mServerDT = new Date(t)
monthNames = new Array("", "Jan", "Feb", "Mar", "April",
"May", "June", "July", "Aug", "Sept", "Oct", "Nov", "Dec")
Hour = mServerDT.getHours()
Minutes = mServerDT.getMinutes()
Seconds = mServerDT.getSeconds()
Day = mServerDT.getDate()

Hour < 10 ? Hour = "0" + Hour.toString() :
Hour=Hour.toString()
Minutes < 10 ? Minutes = "0" + Minutes.toString() :
Minutes=Minutes.toString()
Seconds < 10 ? Seconds = "0" + Seconds.toString() :
Seconds=Seconds.toString()
Day < 10 ? Day = "0" + Day.toString() : Day=Day.toString()

var clockHandle = true; // Dummy init value
clockHandle = GetElement('ServerDateTime');
if (clockHandle) {
clockHandle.innerHTML = Hour + ":" + Minutes + ":" +
Seconds + " " + monthNames[mServerDT.getMonth()+1] + " " + Day + ", "
+ (mServerDT.getFullYear()+21)
}
t +=500
setTimeout('ServerTime()', 500)
}
// End -->
</script>
</head>

===========================
GetElement.js included as well:

var DOM = (document.getElementById ? 1 : 0);
var IE4DOM = (document.all ? 1 : 0);

function GetElement(id) {
var idHandle = (DOM ? document.getElementById(id) : (IE4DOM ?
document.all[id] : false));
return (idHandle ? idHandle : false);
}
On 20 Dec 2003 08:18:49 GMT, "Evertjan."
<ex**************@interxnl.net> wrote:
Harag wrote on 20 dec 2003 in microsoft.public.inetserver.asp.general:
I think this is in the wrong group but since I don't read others much
or code in java script I was wondering if anyone could help me with
this small problem, as I code mostly in ASP vbscript.

I have the following piece of Javascript client code that displays the
users clock on the browser and updates it every second.


Only coded for IE:

======== times.asp =======

Client timezone corrected server date/time:
<div id=a>Please wait</div>
Client date/time:
<div id=b>Please wait</div>

<script runat=server language=jscript>
gmt=+new Date()
</script>

<script>
var t=+<%=gmt%>
var tOut
function eachSecond(){
tOut=setTimeout('eachSecond()',1000)
a.innerHTML=new Date(t)
b.innerHTML=new Date()
t+=1000
}
eachSecond()
</script>

================


Jul 19 '05 #5
Harag wrote on 20 dec 2003 in microsoft.public.inetserver.asp.general:
<%
' VBscript!!!
DIM GMT
GMT = year(now) & ", "&month(Now)-1&", "&day(now)&",
"&hour(now)&", "&Minute(Now)&", " & second(now)
%>


The problem you make is that serverside vbs "Now" is server local time and
not necessarily GMT or the local time of the client.

Except when server and all clients are in the same timezone, including
summertime definition, this seems an unrealistic approach.

Serverside jscript can as shown be manipulated to show UT = GMT.
Clientside javascript can change this to client local time.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 19 '05 #6
Hi

Yes, this is exactly the time I wanted showing on all clients
machines... the server time.

I'm helping in doing a small multi-player browser game where the
server time is more important to the client than any other time as the
players will do orders that relate to the server time. I just thought
it would be nice to have the clock "ticking" rather than a static
update everytime they refreshed the pages.

Thanks again.

Al.

On 20 Dec 2003 18:49:30 GMT, "Evertjan."
<ex**************@interxnl.net> wrote:
The problem you make is that serverside vbs "Now" is server local time and
not necessarily GMT or the local time of the client.

Jul 19 '05 #7
I couldn't agree more... :)

The clock I want to actual display is the SERVERS time.

Al.

On Sat, 20 Dec 2003 10:42:36 -0500, "Don Verhagen"
<ne**@southeast-florida.com> wrote:

"Harag" <ha***@REMOVETHESECAPITALSsofthome.net> wrote in message
news:89********************************@4ax.com.. .
Hi all
I think this is in the wrong group but since I don't read others much
or code in java script I was wondering if anyone could help me with
this small problem, as I code mostly in ASP vbscript.

I have the following piece of Javascript client code that displays the
users clock on the browser and updates it every second.

[remaining post snipped]

I never understood the purpose of putting the users's clock on a webpage. It
always seems like a waste of resources, especially updating every second.
The user already has a clock, why give them another?

Don


Jul 19 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: JamesBV | last post by:
My PC's Region setting is set to "English (Canada)"... cause I am in Canada (eh?) (: I'm using VB.net, standard edition (v1?) So I wrote my application based on this Region. I've both Short...
8
by: David McDivitt | last post by:
I need to set tabs on java generated pages. Pages have four sections: header, sidebar, body, and footer. The sidebar and body change dynamically. The tab key must go to anchors, fields, and buttons...
1
by: Marius Kaizerman | last post by:
I'm trying to set the current time using now() to a date field on a table which is in sql server. I've tried the following syntax: DoCmd.RunSQL "update openclosepos set closedate= '" & now() &...
18
by: Dixie | last post by:
Can I set the Format property in a date/time field in code? Can I set the Input Mask in a date/time field in code? Can I set the Format of a Yes/No field to Checkbox in code? I am working on...
8
by: David Lozzi | last post by:
Howdy, I have a user control that is a report to display data. On the page the control is inserted in, I have filter options to filter the report. When I try to do something like this, nothing...
0
by: Niketa Mahana | last post by:
Hi, We are in the process of making product in windows forms that is localized presently for all european countries.We are supposed to support all eastern and western european date , time and...
5
by: Amogh | last post by:
Hi, My question is related to setting freed pointers to NULL. After freeing a pointer: 1) Should the freeing routine also be responsible for setting the pointer to null? 2) Or, should the...
3
by: si_owen | last post by:
Hi all, I have a db that records time in the minutes that have passed midnight. I need to pull this back and put it into correct time hh:mm Can anyone help me with setting up the initial...
12
by: skyy | last post by:
Hi.. I am working on Arm-linux os on developement board. The OS reset the time and date whenever the board is reset. Is there any way that i can run a script to set the time/date instead of...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.