get value of date time from server in javascript.

Discussion in 'JavaScript' started by kaps, Apr 19, 2008.

  1. #1
    hi all,
    I have a frame in which i want server date time. every time i click link the time gets adds to text area.

    Can u please help me.
     
    kaps, Apr 19, 2008 IP
  2. kaps

    kaps Guest

    Messages:
    10
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Hi, I got the value of server on jsp, but i cant update it. once i get the value it doesnt change with time.
     
    kaps, Apr 19, 2008 IP
  3. kaps

    kaps Guest

    Messages:
    10
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Hi,
    plz help me out..
    I will be very thank ful to u.
     
    kaps, Apr 20, 2008 IP
  4. kmap

    kmap Well-Known Member

    Messages:
    2,215
    Likes Received:
    29
    Best Answers:
    2
    Trophy Points:
    135
    #4
    write a javascript clock after getting time from server.

    Search on G the code for javascript clock


    Regards

    Alex
     
    kmap, Apr 21, 2008 IP
  5. xrvel

    xrvel Notable Member

    Messages:
    918
    Likes Received:
    30
    Best Answers:
    2
    Trophy Points:
    225
    #5
    Maybe you can use AJAX.

    For example : You have index.jsp
    There is a button and a read-only text field in index.jsp.
    When s/he clicks the button, the text field will be filled with current server time.

    Here're the steps
    1. Create a file for example named time.jsp. When a user visits time.jsp directly in his / her browser, s/he will get the current server time.
      The time is written in JSP code (i don't know the JSP syntax to write the current time).
    2. Now add AJAX code in index.jsp.
      1. When the button is clicked, put the AJAX request here.
      2. a request to time.jsp is made.
      3. The AJAX request result will be inserted in the read only text field, or in any place (in index.php).
     
    xrvel, Apr 21, 2008 IP
  6. kaps

    kaps Guest

    Messages:
    10
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    sorry sir, i m not getting u. plz can u give me the code..
     
    kaps, Apr 21, 2008 IP
  7. xrvel

    xrvel Notable Member

    Messages:
    918
    Likes Received:
    30
    Best Answers:
    2
    Trophy Points:
    225
    #7
    Ok, but i don't know how to get current time in Java (JSP). :)
    Can you give me some lines about how to get current time in Java ?
     
    xrvel, Apr 21, 2008 IP
  8. wd_2k6

    wd_2k6 Peon

    Messages:
    1,740
    Likes Received:
    54
    Best Answers:
    0
    Trophy Points:
    0
    #8
    I'm not sure if this is even close to what you want but is it something like this:

    <html>
        <head>
    <script type="text/javascript">
    var today = new Date();
    </script>
    
          
        </head>
        <body>
    <form> 
    <textarea name="textarea1">
    </textarea>
    <input type="button" value="ADD DATE" onClick="this.form.textarea1.value+=[new Date()]"> 
    </form> 
    
    
        </body>
    </html>
    
    Code (markup):
     
    wd_2k6, Apr 21, 2008 IP