Write local time to page

2012-08-15  Source: Original Site  Category:JavaScript  Views:0 

Advertisement

How can I modify this script so that the local time shows on my home page at load, with no button- or link-clicking necessary? In other words, I want my local time to write automatically on my home page at load, but I don't want it in a separate alert box/window.

I tried changing "alert" in the function to "document.write" and calling the function in the body, and it does write, but ON A TOTALLY SEPARATE PAGE from my home page. If I keep the "alert" as-is, and call the function in the body, the time writes in an alert window. Again, not what I want. Any ideas?

<head>

<SCRIPT LANGUAGE="JavaScript">

<!-- 540 from 9*60 because I'm in South Korea, which is GMT+8 and DST -->
<!-- Begin
function showlocaltime() {
var today = new Date();
var difftime = (today.getTimezoneOffset()+540) *60000;
today.setTime(today.getTime()+difftime);
alert(today.toLocaleString());
}
// End -->
</script>

</head>

<body>

<div align="center">
Click <a href="javascript:showlocaltime()">[here]</a> to find the current local time.
</div>

Related articles
  • Write local time to page 2012-08-15

    How can I modify this script so that the local time shows on my home page at load, with no button- or link-clicking necessary? In other words, I want my local time to write automatically on my home page at load, but I don't want it in a separate aler

  • Convert from UTC Time zone to Local TIme Zone 2012-01-21

    I am working on a web application which stores all Dates in GMT time zone. When I display the dates to the user I need to display them in their local time zone. So for example in my DB I have a date 08.07.2009 14:45:23 and this is GMT time When the u

  • Oracle timestamp with local time zone problem 2012-01-24

    Apex 2.2.1, db 10.2.0.1.0 My app's tables contain columns with TIMESTAMP (0) WITH LOCAL TIME ZONE datatypes. Times entered into these columns via Apex are being incorrectly stored. I have an App-level process (on load before header) which sets the us

  • Keeping track of time on page with PHP? 2012-01-31

    I need to keep track of the time someone is on a page, start and end will be triggered by events so that isn't too difficult but I wanted to also keep a sort of running time going that is updated every minute. I'm not sure where I would even put this

  • Oracle Confused about how TIMESTAMP WITH LOCAL TIME ZONE works 2012-02-20

    I had a column defined as TIMESTAMP, and I'm mapping this with Java Hibernate to a java.sql.Timestamp object. I discovered that this causes me a problem, because I often have to run a script in PST that writes this column, but will be read in CST, an

  • Javascript question about date() and local time 2012-07-10

    I'm trying to write a script that takes a UNIX timestamp and returns the user's date and time in his or her local time. Here's my code: function getLocalTime(GMTtime) { var GMTtime = GMTtime * 1000; var newDate = new Date(GMTtime); return newDate; }

  • getting users local time 2012-07-11

    Is it possible for me to get the local time/date from a user that visits a page of mine as opposed to the server time/date?

  • Count Down and Local Time 2012-08-10

    Can you please help? I've got Count Down to the race (for instance) and local time which you can choose from drop down menu... The big problem is: Local time is working...which is ok but "The Count Down" doesn't want to work and I don't have an idea

  • World local time 2012-09-20

    I want to display local time on the page based on user's selected country. Is there any FREE API available for getting local time of any country. Input may be whatever, country or longitude and latitude.

  • Convert UTC time to local time ? 2012-12-28

    Using AIX6.1 box. I have UTC time value and need to convert it to local time value - I mean time zone and DST should be taken into consideration. I hope it could be done using shell environment - I don't want to write a program.

  • I want to insert local time & date in my site 2013-03-12

    Wednesday 25 May 2008 | 13:01 GMT+2 | Cyprus-EU I want to insert local time & date in my site , well zone is GMT+2 , below is correct for date , what about time ? <script language="JavaScript" type="text/javascript"><!-- var months = new

  • Display MySQL timestamp in user's local time 2013-05-20

    Hello. I would like to display a MySQL time stamp in the user's local time. I have this code already that will get/display the user's current date/time: <script type="text/javascript"> function Gettime() { var now = new Date(); //var currenthou

  • Time based page?? 2013-06-10

    I hope i'm in the right forum for this question, basically is it possible to get a page to, redirect to either one of two pages based on a specific date and time, for example:- date will be Sat 4th Dec & Time 6:00PM user logins in goes to page1.h

  • Lat/Long and Local Time 2013-06-15

    Hello i want to write a code to convert Lat/Long cordinates of world map to Local Time of time zone. That is if input is Lat/Long then output should be local time of that lat/long position of the world. Please if you ppl can give information about it

  • Local Time 2013-10-30

    I am using this function to caculate the days left to the start of a race. function timeleft() { return Round((mktime(0, 0, 0, 11, 7, 2004) - time())/86400); } Is the time() part using the local time of the users machine or the server hosting the pag

  • how do i auto adjust time base on user local time 2014-08-29

    how do i auto adjust time base on user local time i want to put in a time like 1:00pm us time manually, how can i make this number automaticly change to whaterver time equivalent in user local timezone <html> <head> <title>Untitled

  • Write to a HTML page using PHP? 2015-06-02

    i've been using a wordpress blog for a while now, and i recently decided i'm tired of the hassle of having to manage all the plugins, spam comments and updates. i don't know a lot about php either, however i am a web designer by hobby: so i decided t

  • Ubuntu Dapper Released on Time? - Please Tell us your Location & Local Time Now... 2012-01-14

    Please Tell us your Location & Local Time now: My Data: -------- Location: Athens (Greece) Date: Thursday 1 June 2006 Local Time: 11:35 am On Schedule (Local) Remaining Time: 12,5 hours left to launch Dapper & still be on Schedule (e.g. Thurs

  • jQuery Problem with .click even fired as many times the page refreshes 2012-01-17

    I have the followin code in my html <script type="text/javascript"> jQuery(function() { jQuery('#slickbox').hide('fast'); jQuery('#slick-toggle').click(function() { jQuery('#slickbox').toggle('blind',350); return false; }); }); </script>

  • Ubuntu changing Local timer interrupts/high precision event timer 2012-01-23

    is it possible to change, how often a processor is interrupted by either the local timer interrupt (LOC) or the high precision event timer (hpet)? (Possibly without having to change the kernel)? More specifically I want to decrease the frequency. Man