Welcome to the Cumulus Support forum.

Latest Cumulus MX V4 release 4.4.2 (build 4085) - 12 March 2025

Latest Cumulus MX V3 release 3.28.6 (build 3283) - 21 March 2024

Legacy Cumulus 1 release 1.9.4 (build 1099) - 28 November 2014
(a patch is available for 1.9.4 build 1099 that extends the date range of drop-down menus to 2030)

Download the Software (Cumulus MX / Cumulus 1 and other related items) from the Wiki

If you are posting a new Topic about an error or if you need help PLEASE read this first viewtopic.php?p=164080#p164080

Live Clock on a website?

Other discussion about creating web sites for Cumulus that doesn't have a specific subforum

Moderator: daj

User avatar
Rainfallman
Posts: 1
Joined: Fri 10 Feb 2012 10:19 am
Weather Station: Aercus WS 3083
Operating System: Windows 10 Pro 64bit
Location: Fairlight Cove, East Sussex, United Kingdom
Contact:

Re: Live Clock on a website?

Post by Rainfallman »

Have a look at the world time server at http://www.worldtimeserver.com/ you can place a clock on a web page for any time zone. It may solve your problem.
rainfallman
duke

Re: Live Clock on a website?

Post by duke »

Can some one tell me how to reconfigure this script to adjust BST on last sunday in march and last sunday in october?

From the authors website the script currently adjusts for:
To get the clock adjusting for daylight savings time between the first Sunday in October and the first Sunday in April (which is when it applies here) I added:
The script:

Code: Select all

// code to adjust for daylight saving time
 var gmt = new Date;var lsm = new Date;var lso = new Date;
 lsm.setMonth(3);lsm.setDate(7);
 var day = lsm.getDay();lsm.setDate(7-day);
 lso.setMonth(9);lso.setDate(7);
 day = lso.getDay();lso.setDate(7-day);
 if (gmt < lsm || gmt >= lso) dst = 1; 
Link to the site:Analogue Clock

Duke
User avatar
beteljuice
Posts: 3292
Joined: Tue 09 Dec 2008 1:37 pm
Weather Station: None !
Operating System: W10 - Threadripper 16core, etc
Location: Dudley, West Midlands, UK

Re: Live Clock on a website?

Post by beteljuice »

Try:

Code: Select all

// code to adjust for daylight saving time
var gmt = new Date;var lsm = new Date;var lso = new Date;
lsm.setMonth(2);lsm.setDate(31);
var day = lsm.getDay();lsm.setDate(31-day);
lso.setMonth(9);lso.setDate(31);
day = lso.getDay();lso.setDate(31-day);
if (gmt > lsm && gmt < lso) dst = 1; 
... be warned the beteljuice always has problems with dates no matter what the code :roll:

Edit: debug alert line removed
Edit#2: Last line corrected :oops:
Last edited by beteljuice on Mon 26 Mar 2012 12:17 pm, edited 2 times in total.
Image
......................Imagine, what you will KNOW tomorrow !
duke

Re: Live Clock on a website?

Post by duke »

beteljuice wrote: ... be warned the beteljuice always has problems with dates no matter what the code :roll:
Unfortunately it did not work :(

I don't understand js at all at the moment so I don't know where to start. Thanks for trying.

I've set the clock on my site manually at the moment but I really would like to solve this if some one knows how.

Thanks.

Duke
duke

Re: Live Clock on a website?

Post by duke »

I finally found what I was after :D . I guess this code (or something similar) would work for any js clock so I'll post it here.

To me it looks the same as beteljuice code so I don't understand why that did not work. May be op error ;) .
Here (in Sydney) we usually go onto daylight savings time at 2am on the last Sunday in October and back to standard time at 3am on the last Sunday in March. The following code will perform this switch at midnight visitor local time on those dates which is within a day of the correct time for the change. (To be more accurate than this would require about three times as much code which I don't think is worth it in this instance).

Code: Select all

var gmt = new Date;
 var lsm = new Date;
 var lso = new Date;
 lsm.setMonth(2); // March
 lsm.setDate(31);
 var day = lsm.getDay();// day of week of 31st
 lsm.setDate(31-day); // last Sunday
 lso.setMonth(9); // October
 lso.setDate(31);
 day = lso.getDay();
 lso.setDate(31-day);
 if (gmt < lsm || gmt >= lso) dst = 1; 
You would of course need to change the code to determine the appropriate dates for your local circumstances. Note that the month numbers run 0 = January through 11 = December and not 1 through 12.
Hope the code or explanation helps some one.

Duke
User avatar
beteljuice
Posts: 3292
Joined: Tue 09 Dec 2008 1:37 pm
Weather Station: None !
Operating System: W10 - Threadripper 16core, etc
Location: Dudley, West Midlands, UK

Re: Live Clock on a website?

Post by beteljuice »

I left a debug 'alert' in the code sorry.

Yes that's the same thing except I reversed the operands for the dst decision.
In my code dst = 1 at the moment because dst is in the 'Summer' for UK, whereas that (Australian) code dst is in UK 'Winter' - so that code should be backwards for the UK showing GMT hours ???
Last edited by beteljuice on Mon 26 Mar 2012 10:41 am, edited 1 time in total.
Image
......................Imagine, what you will KNOW tomorrow !
duke

Re: Live Clock on a website?

Post by duke »

Thanks beteljuice. As suspected, op error crept in last night :oops: . When I cut and paste your code I pasted over "var dst = 0;" and that stopped the code working. Back in now and your code works a treat.

Therefore,
... be warned the beteljuice always has problems with dates no matter what the code
not true :D .

Cheers.

Duke
User avatar
beteljuice
Posts: 3292
Joined: Tue 09 Dec 2008 1:37 pm
Weather Station: None !
Operating System: W10 - Threadripper 16core, etc
Location: Dudley, West Midlands, UK

Re: Live Clock on a website?

Post by beteljuice »

duke wrote: Therefore,
... be warned the beteljuice always has problems with dates no matter what the code
not true :D .
VERY true :oops:

I didn't finish reversing the logic !

Code: Select all

// if (gmt > lsm || gmt < lso) dst = 1; 
// should be

if (gmt > lsm && gmt < lso) dst = 1; 
but if you are feeling brave you could try:

Code: Select all

// code to adjust for daylight saving time
// mod by beteljuice to get last Sunday of month(s)
var gmt = new Date;var lsm = new Date;var lso = new Date; var dst=0;
lsm.setMonth(2);lsm.setDate(31); // 'Summer' start 2 = March which has 31 days
var day = lsm.getDay();lsm.setDate(31-day); // find the date of last Sunday in month
lsm.setUTCHours(0, 59, 59, 0); // clocks change 01:00 hrs UTC
lso.setMonth(9);lso.setDate(31); // 'Winter' start 9 = October which has 31 days
day = lso.getDay();lso.setDate(31-day); // find the date of last Sunday in month
lso.setUTCHours(0, 59, 59, 0); // clocks change 01:00 hrs UTC
if (gmt > lsm && gmt < lso) dst = 1; 
Image
......................Imagine, what you will KNOW tomorrow !
duke

Re: Live Clock on a website?

Post by duke »

beteljuice wrote: but if you are feeling brave you could try:

Code: Select all

// code to adjust for daylight saving time
// mod by beteljuice to get last Sunday of month(s)
var gmt = new Date;var lsm = new Date;var lso = new Date; var dst=0;
lsm.setMonth(2);lsm.setDate(31); // 'Summer' start 2 = March which has 31 days
var day = lsm.getDay();lsm.setDate(31-day); // find the date of last Sunday in month
lsm.setUTCHours(0, 59, 59, 0); // clocks change 01:00 hrs UTC
lso.setMonth(9);lso.setDate(31); // 'Winter' start 9 = October which has 31 days
day = lso.getDay();lso.setDate(31-day); // find the date of last Sunday in month
lso.setUTCHours(0, 59, 59, 0); // clocks change 01:00 hrs UTC
if (gmt > lsm && gmt < lso) dst = 1; 
Bravery in hand ;) . Copy - paste - FTP. Wait for page to load. Correct time displayed on site and local host. :clap:

Thanks for your time.

Duke
RayProudfoot
Posts: 3602
Joined: Wed 06 May 2009 6:29 pm
Weather Station: Davis VP2 with Daytime FARS
Operating System: Windows XP SP3
Location: Cheadle Hulme, Cheshire, England
Contact:

Re: Live Clock on a website?

Post by RayProudfoot »

I've added the code for an analogue clock on my website. Could someone outside GMT+1 please check it shows UK time and not your own time zone please?
http://www.cheadlehulmeweather.co.uk/index.htm

Thanks.
Cheers,
Ray, Cheshire.

Image
tobyspond
Posts: 252
Joined: Fri 24 Jun 2011 5:57 pm
Weather Station: Davis Vantage Pro2
Operating System: Windows 10
Location: Lamoine, Maine, USA

Re: Live Clock on a website?

Post by tobyspond »

Hi Ray,

Your clock appears to be showing the correct time. My local time is 10 am (eastern US) and your clock displayed 3 pm.

Kerry
RayProudfoot
Posts: 3602
Joined: Wed 06 May 2009 6:29 pm
Weather Station: Davis VP2 with Daytime FARS
Operating System: Windows XP SP3
Location: Cheadle Hulme, Cheshire, England
Contact:

Re: Live Clock on a website?

Post by RayProudfoot »

Brilliant. Thanks Kerry.
Cheers,
Ray, Cheshire.

Image
gemini06720
Posts: 1700
Joined: Mon 10 Aug 2009 10:16 pm
Weather Station: No weather station
Operating System: No operating system
Location: World...

Re: Live Clock on a website?

Post by gemini06720 »

Ray, it is not showing the correct time in my browser - it is 20:40 here (local pacific daylight saving time) and the clock on the web page is displaying 04:40 AM... :(

You might want to have a look at the small JavaScript utility Duke is using on his web pages. ;)

Oh, did I forget to mention that I really dislike (to put it nicely) those gadgets with mouse-hover messages and links... :twisted:
User avatar
beteljuice
Posts: 3292
Joined: Tue 09 Dec 2008 1:37 pm
Weather Station: None !
Operating System: W10 - Threadripper 16core, etc
Location: Dudley, West Midlands, UK

Re: Live Clock on a website?

Post by beteljuice »

Could someone outside GMT+1 please check it shows UK time and not your own time zone please?
Image
......................Imagine, what you will KNOW tomorrow !
User avatar
PaulMy
Posts: 4355
Joined: Sun 28 Sep 2008 11:54 pm
Weather Station: Davis VP2 Plus 24-Hour FARS
Operating System: Windows8 and Windows10
Location: Komoka, ON Canada
Contact:

Re: Live Clock on a website?

Post by PaulMy »

At 12:15 a.m. here it seems to be showing your 5:15 time correctly.
Paul
VP2+
C1 www.komokaweather.com/komokaweather-ca
MX https://komokaweather.com/cumulusmx/index.htm /index.html /index.php
MX https://komokaweather.com/cumulusmxwll/index.htm /index.html /index.php
MX https:// komokaweather.com/cumulusmx4/index.htm
Image
Post Reply