473,557 Members | 2,831 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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('MyD ateTime');
if (clockHandle) {
clockHandle.inn erHTML = mDateTime1[1] + " " +
mDateTime1[2] + ", " + mDateTime1[4] + ", " + mDateTime1[3];
}
setTimeout("New Time()",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 4888
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***@REMOVETH ESECAPITALSsoft home.net> wrote in message
news:89******** *************** *********@4ax.c om...
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('MyD ateTime');
if (clockHandle) {
clockHandle.inn erHTML = mDateTime1[1] + " " +
mDateTime1[2] + ", " + mDateTime1[4] + ", " + mDateTime1[3];
}
setTimeout("New Time()",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.publi c.inetserver.as p.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=jscrip t>
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***@REMOVETH ESECAPITALSsoft home.net> wrote in message
news:89******** *************** *********@4ax.c om...
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="VBScr ipt" %>
<% Option Explicit %>
<%
' VBscript!!!
DIM GMT
GMT = year(now) & ", "&month(Now )-1&", "&day(now)& ",
"&hour(now) &", "&Minute(Now)&" , " & second(now)
%>

<head>
<script language="JavaS cript1.2" type="text/javascript">
<!-- Begin
function UserTime()
{
mDateTime1 = Date().split(" ");
var clockHandle = true; // Dummy init value
clockHandle = GetElement('MyD ateTime');
if (clockHandle) {
clockHandle.inn erHTML = mDateTime1[1] + " " +
mDateTime1[2] + ", " + mDateTime1[4] + ", " + mDateTime1[3];
}
setTimeout("Use rTime()", 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.getHo urs()
Minutes = mServerDT.getMi nutes()
Seconds = mServerDT.getSe conds()
Day = mServerDT.getDa te()

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

var clockHandle = true; // Dummy init value
clockHandle = GetElement('Ser verDateTime');
if (clockHandle) {
clockHandle.inn erHTML = Hour + ":" + Minutes + ":" +
Seconds + " " + monthNames[mServerDT.getMo nth()+1] + " " + Day + ", "
+ (mServerDT.getF ullYear()+21)
}
t +=500
setTimeout('Ser verTime()', 500)
}
// End -->
</script>
</head>

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

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

function GetElement(id) {
var idHandle = (DOM ? document.getEle mentById(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.publi c.inetserver.as p.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=jscrip t>
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.publi c.inetserver.as p.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**@southea st-florida.com> wrote:

"Harag" <ha***@REMOVETH ESECAPITALSsoft home.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
2534
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 and Long dates being displayed (including a DateTimePicker). BUT... at work, there are some machines which the Region is the ol' default of...
8
9695
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 doing all in the header first, all in the sidebar second, etc. A base page contains includes for all the pieces and has the body tag. I am...
1
6184
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() & "' where openid= '" & tmpopen & "'" but then I get an error which says that it cannot enter a string value into a date field.
18
18331
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 a remote update of tables and fields and can't find enough information on these things. Also, how do you index a field in code?
8
2256
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 happens. dim filt as string ... build filter string... UserControl.ReportFilter = filt
0
1229
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 number formats.However we are currently facing a problem that say a user in Italy uses our product and user's settings have a "." as a time seperator...
5
3149
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 client/user code be responsible for doing it? On what basis should a decision be made favouring either case ?
3
1327
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 time to midnight?? Thanks in Advance,
12
5550
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 manually setting it? Thanks..
0
7626
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7549
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8061
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7591
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
1
5454
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5172
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3599
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3577
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2044
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.