Former Member
inherit
guest@proboards.com
265702
0
Nov 27, 2024 0:09:34 GMT -8
Former Member
0
January 1970
Former Member
|
Post by Former Member on Nov 14, 2022 6:16:56 GMT -8
Hi everyone. I once had a javascript that listed my current time zone and I would like to make a list of my time zone and a few others, do you know...or can you point me in the right direction?
Something like this
I can see the "run snippet" works on that page, but I can't make it work on my new custom page
<html> <script> const str = new Date().toLocaleString('en-US', { timeZone: 'Asia/Jakarta' }); </script> </html>
|
|
Former Member
inherit
guest@proboards.com
265702
0
Nov 27, 2024 0:09:34 GMT -8
Former Member
0
January 1970
Former Member
|
Post by Former Member on Nov 14, 2022 22:45:52 GMT -8
<html>
<p>Hawaii: <span class="clock" data-timezone="Pacific/Honolulu"></span></p> <p>Los Angeles (PST): <span class="clock" data-timezone="America/Los_Angeles"></span></p> <p>Arizona (MST): <span class="clock" data-timezone="America/Phoenix"></span></p> <p>Denver (MST): <span class="clock" data-timezone="America/Denver"></span></p> <p>Chicago (CST): <span class="clock" data-timezone="America/Chicago"></span></p> <p>New York (EST): <span class="clock" data-timezone="America/New_York"></span></p> <p>Puerto Rico: <span class="clock" data-timezone="America/Dominica"></span></p> <br> <br> Over the Atlantic Ocean🌊 <br> <br> <p>Gambia: <span class="clock" data-timezone="Africa/Banjul"></span></p> <p>Romania: <span class="clock" data-timezone="Europe/Bucharest"></span></p> <p>Uganda: <span class="clock" data-timezone="Africa/Kampala"></span></p> <p>Bangladesh: <span class="clock" data-timezone="Asia/Dacca"></span></p> <p>Japan (JST): <span class="clock" data-timezone="Asia/Tokyo"></span></p> <br> <br> Over the Pacifico Ocean🌊 <br> <br>
<script>
const clocks = document.getElementsByClassName("clock");
function updateClocks() { for (let clock of clocks) { let timezone = clock.dataset.timezone; let time = new Date().toLocaleTimeString("en-US", { hour: '2-digit', minute:'2-digit', timeZone: timezone }); clock.textContent = time; } }
// Update every minute: setInterval(updateClocks, 60000); updateClocks();
// References I found // https://stackoverflow.com/questions/59716981/iana-timezones-for-mainland-united-states#:~:text=IANA%20Timezones%20for%20mainland%20United%20States%201%20Eastern,time%20zone%3A%20America%2FDenver%204%20Pacific%20time%20zone%3A%20America%2FLos_Angeles // https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
</script> </html>
|
|
Former Member
inherit
guest@proboards.com
265702
0
Nov 27, 2024 0:09:34 GMT -8
Former Member
0
January 1970
Former Member
|
Post by Former Member on Nov 14, 2022 22:46:55 GMT -8
I found that post and got that code and use it.
|
|
inherit
6871
0
Jun 10, 2024 2:25:35 GMT -8
bigballofyarn
"If you wish to make an apple pie from scratch, you must first invent the universe." -Carl Sagan
7,897
January 2003
bigballofyarn
|
Post by bigballofyarn on Nov 15, 2022 5:29:47 GMT -8
On which forum did you place the code? Maybe we can see it in action.
|
|
Former Member
inherit
guest@proboards.com
265702
0
Nov 27, 2024 0:09:34 GMT -8
Former Member
0
January 1970
Former Member
|
Post by Former Member on Nov 15, 2022 5:52:38 GMT -8
|
|
inherit
140147
0
Nov 19, 2024 5:07:22 GMT -8
Nscalerr
Throw me to the wolves and I'll return leading the pack!
3,043
May 2009
nscalerr
|
Post by Nscalerr on Nov 15, 2022 20:52:49 GMT -8
Btw you don't need the <html> and </html> tags. Looks great and I pinched the idea for my forum - hehehe
|
|
Former Member
inherit
guest@proboards.com
265702
0
Nov 27, 2024 0:09:34 GMT -8
Former Member
0
January 1970
Former Member
|
Post by Former Member on Nov 15, 2022 22:56:13 GMT -8
oh, thank you. yeah, I'm new and don't understand much, but I'll remove them soon. , I like how internet people share their knowledge. I have contacts in all of those time zones and I kind of do it for me..
|
|
inherit
First Contributor
66253
0
Mar 18, 2024 11:09:20 GMT -8
aRMY83
2,925
December 2005
army83
|
Post by aRMY83 on Nov 17, 2022 9:19:22 GMT -8
Hello @dominiccfj,
Likewise, looks great and I also "pinched" the idea and placed it on my site.
p.s. thanks for sharing this...
|
|
Former Member
inherit
guest@proboards.com
267271
0
Nov 27, 2024 0:09:34 GMT -8
Former Member
0
January 1970
Former Member
|
Post by Former Member on Dec 17, 2022 1:06:37 GMT -8
my old post
|
|