By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,287 Members | 1,668 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,287 IT Pros & Developers. It's quick & easy.

Need script showing time minus 7 hrs

P: n/a
I need a script for my site that shows my servertime minus 7 hours.
Anyone who can help?
Dec 9 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Jumbo wrote:
I need a script for my site that shows my servertime minus 7 hours.
Anyone who can help?


In JScript(.NET)/ASP (untested):

<%@ LANGUAGE = JScript %>
...
<%
var d = new Date();
d.setHours(d.getHours() - 7);
%>
<%= d.toString() %>

See
<URL:http://msdn.microsoft.com/library/en-us/jscript7/html/jsmthsethours.asp>
PointedEars
Dec 9 '05 #2

P: n/a
On Fri, 09 Dec 2005 02:28:47 +0100, Thomas 'PointedEars' Lahn
<Po*********@web.de> wrote:
Jumbo wrote:
I need a script for my site that shows my servertime minus 7 hours.
Anyone who can help?


In JScript(.NET)/ASP (untested):

<%@ LANGUAGE = JScript %>
...
<%
var d = new Date();
d.setHours(d.getHours() - 7);
%>
<%= d.toString() %>

See
<URL:http://msdn.microsoft.com/library/en-us/jscript7/html/jsmthsethours.asp>
PointedEars

Thanks, but do I place the code in the header?
Dec 9 '05 #3

P: n/a
Jumbo wrote:
[...] Thomas 'PointedEars' Lahn [...] wrote:
Jumbo wrote:
I need a script for my site that shows my servertime minus 7 hours.
Anyone who can help?


In JScript(.NET)/ASP (untested):
[1] <%@ LANGUAGE = JScript %>
...
[2] <%
var d = new Date();
d.setHours(d.getHours() - 7);
%>
[3] <%= d.toString() %>

[...]


Thanks, but do I place the code in the header?


No. (HTTP) headers are not parsed by ASP(.NET).
(If you mean the (X)HTML `head' element by `header': it depends.)

[1] AFAIK must be placed before any other server-side script code.
See MSDN Library for details.

[2] can be placed anywhere after [1] and before [3], for easy
maintenance probably right before [3] as written here.

[3] should be placed where the date string is to be included.

Please learn how to quote:
<http://jibbering.com/faq/faq_notes/pots1.html#ps1Post>
PointedEars
Dec 9 '05 #4

P: n/a
JRS: In article <sv********************************@4ax.com>, dated
Fri, 9 Dec 2005 01:48:24 local, seen in news:comp.lang.javascript, Jumbo
<ng*@mail.dk> posted :
I need a script for my site that shows my servertime minus 7 hours.
Anyone who can help?


But what is servertime - UTC or local?

If it is local, what is servertime minus 7 hours when the true time is
2006-03-26 04:00 UTC (assuming a Danish server)? 21:00 or 20:00 ?

Javascript on a Web page - the prime topic of this group - has no access
to servertime; but, if the local computer is correctly set, it does have
access to UTC, from which the local time at any location for which the
Summer Time rules are known can be calculated.

Read the FAQ; see below.

--
John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4
<URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Dec 9 '05 #5

P: n/a
On Fri, 9 Dec 2005 21:57:01 +0000, Dr John Stockton
<jr*@merlyn.demon.co.uk> wrote:
JRS: In article <sv********************************@4ax.com>, dated
Fri, 9 Dec 2005 01:48:24 local, seen in news:comp.lang.javascript, Jumbo
<ng*@mail.dk> posted :
I need a script for my site that shows my servertime minus 7 hours.
Anyone who can help?


But what is servertime - UTC or local?

If it is local, what is servertime minus 7 hours when the true time is
2006-03-26 04:00 UTC (assuming a Danish server)? 21:00 or 20:00 ?

Javascript on a Web page - the prime topic of this group - has no access
to servertime; but, if the local computer is correctly set, it does have
access to UTC, from which the local time at any location for which the
Summer Time rules are known can be calculated.


I thought this would always show my time..........
Dec 10 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.