473,725 Members | 2,278 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 4895
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
2553
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 "English (United States)". Canadian:
8
9704
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 trying to use code pasted below. Help would be appreciated. Thanks <script language="javascript"> <!--
1
6192
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
18408
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
2264
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
1238
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 sql server is unable to insert such time values into the database.We get an error for date-time...
5
3168
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
1337
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
5563
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
9401
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9179
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
8099
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6702
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6011
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4519
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4784
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3228
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
2
2637
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.