473,405 Members | 2,334 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,405 software developers and data experts.

Time Zones

Hi

Would anyone have an example of working out international time zones,
using an array.

Greg

Sep 23 '06 #1
9 1382
JRS: In article <11**********************@k70g2000cwa.googlegroups .com>,
dated Sat, 23 Sep 2006 01:55:47 remote, seen in
news:comp.lang.javascript, Gregc. <gr*********@bigpond.composted :
>Would anyone have an example of working out international time zones,
using an array.
A remarkably ambiguous question. Read
<URL:http://www.merlyn.demon.co.uk/js-dates.htmff. (incl date5)
and <URL:http://www.merlyn.demon.co.uk/misctime.htmthen reformulate.

It's a good idea to read the newsgroup and its FAQ.
--
© 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.htmjscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/TP/BP/Delphi/jscr/&c, FAQ items, links.
Sep 23 '06 #2

Dr John Stockton wrote:
A remarkably ambiguous question. Read
<URL:http://www.merlyn.demon.co.uk/js-dates.htmff. (incl date5)
and <URL:http://www.merlyn.demon.co.uk/misctime.htmthen reformulate.

It's a good idea to read the newsgroup and its FAQ.
--
© 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.htmjscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/TP/BP/Delphi/jscr/&c, FAQ items, links.
Thanks but already looked on your website.

Greg

Sep 24 '06 #3
JRS: In article <11*********************@i42g2000cwa.googlegroups. com>,
dated Sat, 23 Sep 2006 20:25:12 remote, seen in
news:comp.lang.javascript, Gregc. <gr*********@bigpond.composted :
>
Dr John Stockton wrote:
>A remarkably ambiguous question. Read
<URL:http://www.merlyn.demon.co.uk/js-dates.htmff. (incl date5)
and <URL:http://www.merlyn.demon.co.uk/misctime.htmthen reformulate.

It's a good idea to read the newsgroup and its FAQ.
--
© 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.htmjscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/TP/BP/Delphi/jscr/&c, FAQ items, links.

Thanks but already looked on your website.
Then you should know :-

a) Not to quote signatures.

b) Enough to ask an answerable question. Note that, as of about 18:20
GMT today, no-one shows any sign of understanding which meaning your
question might have been intended to have. You've not even indicated
your location, so we don't know whether US zones are to be included.
--
© John Stockton, Surrey, UK. REPLYyyww merlyn demon co uk Turnpike 4 ©
Web <URL:http://www.uwasa.fi/~ts/http/tsfaq.html-Timo Salmi: Usenet Q&A.
Web <URL:http://www.merlyn.demon.co.uk/news-use.htm: about usage of News.
No Encoding. Quotes precede replies. Snip well. Write clearly. Mail no News.
Sep 24 '06 #4
Gregc. wrote:
Dr John Stockton wrote:
A remarkably ambiguous question. Read
<URL:http://www.merlyn.demon.co.uk/js-dates.htmff. (incl date5)
and <URL:http://www.merlyn.demon.co.uk/misctime.htmthen reformulate.
[...]
Thanks but already looked on your website.
As John said, you need to supply a bit more information in your
question - most people won't waste time guessing possible answers to
something so vague, or to ask questions trying to find out what it is
that you want. So...

What do you want to do - send out a date and time that will be
displayed in a users' local timezone? Let the user input dates and
times and convert them to your server's local time? Convert solar time
to astronomical time?

The general strategy is to convert stuff to UTC and then turn it into
whatever local time as appropriate - usually just for display. But
that may not suit or be required in your case. More information is
required.
--
Rob

Sep 24 '06 #5

RobG wrote:
As John said, you need to supply a bit more information in your
question - most people won't waste time guessing possible answers to
something so vague, or to ask questions trying to find out what it is
that you want. So...

What do you want to do - send out a date and time that will be
displayed in a users' local timezone? Let the user input dates and
times and convert them to your server's local time? Convert solar time
to astronomical time?

The general strategy is to convert stuff to UTC and then turn it into
whatever local time as appropriate - usually just for display. But
that may not suit or be required in your case. More information is
required.
--

Okay, well this is what I am trying to do:

HTML>
<HEAD>
<SCRIPT LANGUAGE=javascript type="text/javascript">

var selectedCity;
var timeDiff;
var arrTimeZones = new Array();
arrTimeZones [0] = "Paris;+;1;;"
arrTimeZones [1] = "London;+;0;;"
arrTimeZones [2] = "Rome;+;1;;"
arrTimeZones [3] = "New York City;-;5;;"
arrTimeZones [4] = "Toronto;-;5;;"
arrTimeZones [5] = "Sydney;+;10;;"
arrTimeZones [6] = "Moscow;+;3;;"
arrTimeZones [7] = "Tokyo;+;9;;"
arrTimeZones [8] = "Beijing;+;8;;"
arrTimeZones [9] = "San Francisco;-;8;;"
arrTimeZones [10] = "Cairo;+;2;;"
arrTimeZones [11] = "Bangkok;+;7;;"
arrTimeZones [12] = "Lima;-;5;;"
function window_onload() {
updateTimeZone();
window.setInterval("updateTimeZone()", 1000);
}
function updateTimeZone()
{
var lstCity = document.form1.lstCity;
timeDiff = lstCity.options[lstCity.selectedIndex].value;
selectedCity = lstCity.options[lstCity.selectedIndex].text;
updateTime();


}
function getTimeString(dateObject)
{
var timeString;
var hours = dateObject.getHours();
if (hours < 10)
hours = "0" + hours;
var minutes = dateObject.getMinutes();
if (minutes < 10)
minutes = "0" + minutes;

var seconds = dateObject.getSeconds()
if (seconds < 10)
seconds = "0" + seconds;
timeString = hours + ":" + minutes + ":" + seconds;
return timeString;
}
function updateTime()
{
var nowTime = new Date();
var resultsFrame = window.top.resultsFrame.document;
resultsFrame.open()
resultsFrame.write("Local Time is " + getTimeString(nowTime) +
"<BR>");
nowTime.setMinutes(nowTime.getMinutes() +
nowTime.getTimezoneOffset() +
parseInt(timeDiff));
resultsFrame.write(selectedCity + " time is " +
getTimeString(nowTime));
resultsFrame.close();
}

</SCRIPT>
</HEAD>
<BODY LANGUAGE=JavaScript onload="window_onload()">
<FORM NAME=form1>
<SELECT SIZE=5 NAME=lstCity LANGUAGE=JavaScript
onchange="updateTimeZone(this);">

<option>Paris</option>
<option>London</option>
<option>Rome</option>
<option>New York</option>
<option>Toronto</option>
<option>Sydney</option>
<option>Moscow</option>
<option>Tokyo</option>
<option>Beijing</option>
<option>San Francisco</option>
<option>Cairo</option>
<option>Bangkok</option>
<option>Lima</option>

</select>
</td>
</tr>
</table>
</form>
</td>
</tr>
</table>
</body>
</html>

But I am having trouble trying to get it to work. Would anyone have an
idea?

Greg

Sep 25 '06 #6
JRS: In article <11**********************@m73g2000cwd.googlegroups .com>,
dated Mon, 25 Sep 2006 00:30:53 remote, seen in
news:comp.lang.javascript, Gregc. <gr*********@bigpond.composted :
>

Okay, well this is what I am trying to do:

HTML>
<HEAD>
<SCRIPT LANGUAGE=javascript type="text/javascript">
^^^^^^^^^^^^^^^^^^^ deprecated, superfluous.
>
var selectedCity;
var timeDiff;
var arrTimeZones = new Array();
arrTimeZones [0] = "Paris;+;1;;"
arrTimeZones [1] = "London;+;0;;"
arrTimeZones [2] = "Rome;+;1;;"
arrTimeZones [3] = "New York City;-;5;;"
arrTimeZones [4] = "Toronto;-;5;;"
arrTimeZones [5] = "Sydney;+;10;;"
arrTimeZones [6] = "Moscow;+;3;;"
arrTimeZones [7] = "Tokyo;+;9;;"
arrTimeZones [8] = "Beijing;+;8;;"
arrTimeZones [9] = "San Francisco;-;8;;"
arrTimeZones [10] = "Cairo;+;2;;"
arrTimeZones [11] = "Bangkok;+;7;;"
arrTimeZones [12] = "Lima;-;5;;"
var arrTimeZones = ["Paris;+;1;;", ..., "Lima;-;5;;"]
is simpler.
>function window_onload() {
updateTimeZone();
window.setInterval("updateTimeZone()", 1000);
}
Be aware that setInterval(..., 1000) will not fire synchronously with
the seconds of the displaying computer.
>function updateTimeZone()
{
var lstCity = document.form1.lstCity;
timeDiff = lstCity.options[lstCity.selectedIndex].value;
selectedCity = lstCity.options[lstCity.selectedIndex].text;
updateTime();


}
function getTimeString(dateObject)
{
var timeString;
var hours = dateObject.getHours();
if (hours < 10)
hours = "0" + hours;
var minutes = dateObject.getMinutes();
if (minutes < 10)
minutes = "0" + minutes;

var seconds = dateObject.getSeconds()
if (seconds < 10)
seconds = "0" + seconds;
timeString = hours + ":" + minutes + ":" + seconds;
return timeString;
}
Don't repeat code; use a (one-line) Leading Zero function.
>function updateTime()
{
var nowTime = new Date();
var resultsFrame = window.top.resultsFrame.document;
resultsFrame.open()
resultsFrame.write("Local Time is " + getTimeString(nowTime) +
"<BR>");
nowTime.setMinutes(nowTime.getMinutes() +
nowTime.getTimezoneOffset() +
parseInt(timeDiff));
There should be no need to use parseInt; and used thus it will probably
give incorrect results for differences of 08 & 09. Use unary +.

alert(timeDiff) shows me an empty string.
resultsFrame.write(selectedCity + " time is " +
getTimeString(nowTime));
resultsFrame.close();
}

</SCRIPT>
</HEAD>
<BODY LANGUAGE=JavaScript onload="window_onload()">
<FORM NAME=form1>
<SELECT SIZE=5 NAME=lstCity LANGUAGE=JavaScript
onchange="updateTimeZone(this);">

<option>Paris</option>

<option>London</option>
<option>Rome</option>
<option>New
York</option>

<option>Toronto</option>

<option>Sydney</option>

<option>Moscow</option>
<option>Tokyo</option>

<option>Beijing</option>
<option>San
Francisco</option>
<option>Cairo</option>

<option>Bangkok</option>
<option>Lima</option>

</select>
</td>
</tr>
</table>
</form>
</td>
</tr>
</table>
</body>
</html>

But I am having trouble trying to get it to work. Would anyone have an
idea?
Explain what trouble. For me, it fails since window.top.resultsFrame.
document is not an Object; don't presume that everyone sees the same.
Maybe you need to understand the use of "open". You could instead write
to a TextArea, for simplicity.

ISTM that timeDiff is an empty string when in updateTime.

You need to learn how to debug code. Write in smaller pieces, testing
as you go. Function alert() will show the value of a variable.

I see no allowance for the Summer Time rules of each location.

If this is coursework, consider a different career.

If it represents a practical need, then js-date5.htm#Demo serves for any
location (even LHI <g>) and js-date5.htm#SLGD (was SLHD) serves for a
list of locations. While the latter input is a TextArea, the value is
immediately converted to an Array.

It's a good idea to read the newsgroup and its FAQ.
--
© 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.htmjscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/TP/BP/Delphi/jscr/&c, FAQ items, links.
Sep 25 '06 #7

Dr John Stockton wrote:
JRS: In article <11**********************@m73g2000cwd.googlegroups .com>,
dated Mon, 25 Sep 2006 00:30:53 remote, seen in
news:comp.lang.javascript, Gregc. <gr*********@bigpond.composted :


Okay, well this is what I am trying to do:

HTML>
<HEAD>
<SCRIPT LANGUAGE=javascript type="text/javascript">
^^^^^^^^^^^^^^^^^^^ deprecated, superfluous.

var selectedCity;
var timeDiff;
var arrTimeZones = new Array();
arrTimeZones [0] = "Paris;+;1;;"
arrTimeZones [1] = "London;+;0;;"
arrTimeZones [2] = "Rome;+;1;;"
arrTimeZones [3] = "New York City;-;5;;"
arrTimeZones [4] = "Toronto;-;5;;"
arrTimeZones [5] = "Sydney;+;10;;"
arrTimeZones [6] = "Moscow;+;3;;"
arrTimeZones [7] = "Tokyo;+;9;;"
arrTimeZones [8] = "Beijing;+;8;;"
arrTimeZones [9] = "San Francisco;-;8;;"
arrTimeZones [10] = "Cairo;+;2;;"
arrTimeZones [11] = "Bangkok;+;7;;"
arrTimeZones [12] = "Lima;-;5;;"

var arrTimeZones = ["Paris;+;1;;", ..., "Lima;-;5;;"]
is simpler.
function window_onload() {
updateTimeZone();
window.setInterval("updateTimeZone()", 1000);
}

Be aware that setInterval(..., 1000) will not fire synchronously with
the seconds of the displaying computer.
function updateTimeZone()
{
var lstCity = document.form1.lstCity;
timeDiff = lstCity.options[lstCity.selectedIndex].value;
selectedCity = lstCity.options[lstCity.selectedIndex].text;
updateTime();


}
function getTimeString(dateObject)
{
var timeString;
var hours = dateObject.getHours();
if (hours < 10)
hours = "0" + hours;
var minutes = dateObject.getMinutes();
if (minutes < 10)
minutes = "0" + minutes;

var seconds = dateObject.getSeconds()
if (seconds < 10)
seconds = "0" + seconds;
timeString = hours + ":" + minutes + ":" + seconds;
return timeString;
}

Don't repeat code; use a (one-line) Leading Zero function.
function updateTime()
{
var nowTime = new Date();
var resultsFrame = window.top.resultsFrame.document;
resultsFrame.open()
resultsFrame.write("Local Time is " + getTimeString(nowTime) +
"<BR>");
nowTime.setMinutes(nowTime.getMinutes() +
nowTime.getTimezoneOffset() +
parseInt(timeDiff));

There should be no need to use parseInt; and used thus it will probably
give incorrect results for differences of 08 & 09. Use unary +.

alert(timeDiff) shows me an empty string.
resultsFrame.write(selectedCity + " time is " +
getTimeString(nowTime));
resultsFrame.close();
}

</SCRIPT>
</HEAD>
<BODY LANGUAGE=JavaScript onload="window_onload()">
<FORM NAME=form1>
<SELECT SIZE=5 NAME=lstCity LANGUAGE=JavaScript
onchange="updateTimeZone(this);">

<option>Paris</option>

<option>London</option>
<option>Rome</option>
<option>New
York</option>

<option>Toronto</option>

<option>Sydney</option>

<option>Moscow</option>
<option>Tokyo</option>

<option>Beijing</option>
<option>San
Francisco</option>
<option>Cairo</option>

<option>Bangkok</option>
<option>Lima</option>

</select>
</td>
</tr>
</table>
</form>
</td>
</tr>
</table>
</body>
</html>

But I am having trouble trying to get it to work. Would anyone have an
idea?

Explain what trouble. For me, it fails since window.top.resultsFrame.
document is not an Object; don't presume that everyone sees the same.
Maybe you need to understand the use of "open". You could instead write
to a TextArea, for simplicity.

ISTM that timeDiff is an empty string when in updateTime.

You need to learn how to debug code. Write in smaller pieces, testing
as you go. Function alert() will show the value of a variable.

I see no allowance for the Summer Time rules of each location.

If this is coursework, consider a different career.

If it represents a practical need, then js-date5.htm#Demo serves for any
location (even LHI <g>) and js-date5.htm#SLGD (was SLHD) serves for a
list of locations. While the latter input is a TextArea, the value is
immediately converted to an Array.

It's a good idea to read the newsgroup and its FAQ.
--
Thanks for your advice. Personally, I'm not fond of JavaScript. Don't
really appreciate the following either "If this is coursework, consider
a different career."

Sep 26 '06 #8
JRS: In article <11**********************@i3g2000cwc.googlegroups. com>,
dated Mon, 25 Sep 2006 17:38:03 remote, seen in
news:comp.lang.javascript, Gregc. <gr*********@bigpond.composted :
>Lines: 161
>Dr John Stockton wrote:
>It's a good idea to read the newsgroup and its FAQ.
--
Thanks for your advice. Personally, I'm not fond of JavaScript. Don't
really appreciate the following either "If this is coursework, consider
a different career."
You have repeatedly been advised to read the FAQ; if you had done so,
you would have known not to over-quote.

You'll be better off in a career matching your intellectual capability.

--
© John Stockton, Surrey, UK. REPLYyyww merlyn demon co uk Turnpike 4 ©
Web <URL:http://www.uwasa.fi/~ts/http/tsfaq.html-Timo Salmi: Usenet Q&A.
Web <URL:http://www.merlyn.demon.co.uk/news-use.htm: about usage of News.
No Encoding. Quotes precede replies. Snip well. Write clearly. Mail no News.
Sep 26 '06 #9
Dr John Stockton wrote on 26 Sep 2006 in comp.lang.javascript:
You'll be better off in a career matching your intellectual capability.
Wow, John, that is just an assumption.

I could put to you some incompatible assumptions,
applicable to different individuals:

A career below that capability could fuel and make time for intellectual
hobbyism, that could enrich life and be a joy when your working days are
over. [This could possibly apply to the majority on this NG?]

A career over that capability could enlarge that capability,
improving one's self esteem.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Sep 27 '06 #10

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

Similar topics

6
by: David Graham | last post by:
Hi I have asked this question in alt.php as the time() function as used in setcookie belongs to php - or does it belong equally in the javascript camp - bit confused about that. Anyway, can anyone...
11
by: lduperval | last post by:
Hi, I`m trying to do date calculations in three types of time zones: local, GMT and specified. The issue I am facing is that I need to be able to specify a date in the proper time zone, and I`m...
1
by: heirou | last post by:
I'm a novice in this subject....I've made a database that requires a time conversion. For example, if local time is 1200, determine the time in Korea. I use two fields: a date field, and a time...
6
by: Rebecca Smith | last post by:
Today’s question involves two time text boxes each set to a different time zone. Initially txtCurrentTime will be set to Pacific Time or system time. This will change with system time as we travel...
0
by: Sabotage | last post by:
Hi all, I am looking to download time zones list for my multilingual software. I found time zones list in english here:...
13
by: maflatoun | last post by:
Hi, I have the following function to convert UTC time to Local time. It works perfect for GMT- (Minus) time zones however it provides incorrect results for GMT+(Plus) time zones? // Format to...
3
by: Satish Itty | last post by:
Hi all, I have a big problem in my hands and not sure how I can fix this. Any suggestions would be greatly appreciated. I have a .NET 3 tier app developed in VS2003 and .NET 1.1. the client is a...
6
by: dredge | last post by:
Hi, the server that hosts my PHP pages has its clock set to Greenwich Mean Time (GMT timezone 0). I need for my PHP scripts to have access to my local time which is Central Standard Time in the...
10
by: WebCM | last post by:
There is a function: http://paste.ubuntu.com/21865 It needs GMT date in YYYY-MM-DD HH:MM:SS format - in SQL: datetime. If date is the same as today, the function returns "Today". There is one...
0
amitpatel66
by: amitpatel66 | last post by:
Hi All, Find below some useful information about Time Zone Conversion in oracle. Hope this would be helpful for many of them since all the real time projects that we work in follow different time...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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,...
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
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...
0
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...

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.