#1
  1. No Profile Picture
    Contributing User
    ASP Discoverer (100 - 499 posts)

    Join Date
    Aug 2005
    Posts
    294
    Rep Power
    39

    Local date with time


    Hello,

    I am using asp.net with javascript to display the local time. What I want is, when I load the page, I should get the time and date in a text box in the format

    dd/mm/yyyy 24hh:mm

    how could I do this? At each refresh of the page, the time and date should change.

    Regards
    Ceema


    I am using the following code to display time


    Code:
    <%@ Page language="c#" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" > 
    
    <html>
    <script type="text/javascript">
    function timeshow()
    {
    
    }
    </script>
    </head>
    <form id="Form1" method="post" runat="server">
    <input type=text onload="timeshow();" name="datetimedis">
    </form>
    	
      </body>
    </html>
  2. #2
  3. No Profile Picture
    Contributing User
    ASP Skiller (1500 - 1999 posts)

    Join Date
    Mar 2005
    Posts
    1,895
    Rep Power
    310
    I don't know .Net or C#, but to get the local date/time you don't need them, just use the JavaScript "Date"

    Comments on this post

    • ceema agrees
  4. #3
  5. No Profile Picture
    Contributing User
    ASP Discoverer (100 - 499 posts)

    Join Date
    Aug 2005
    Posts
    294
    Rep Power
    39

    Thank you


    Hello ,

    Yes, you are right, I tried the code like the following,and it's working fine.

    Regards
    Ceema
    Code:
    <script type="text/javascript">
    
    
    function showLocalTime()
    {
    var dt = new Date();
    var hr = dt.getHours();
    var mi = dt.getMinutes();
    var dat = dt.getDate();
    var mon = dt.getMonth();
    var yea = dt.getYear();
    
    TFRM.Dtname.value = mon + "/" + dat + "/" + yea + "  " + hr + ":" + mi;
    // 
    }
    
    
    
    		</script>
    </HEAD>
    <BODY onload="showLocalTime()">
    <form id="TFRM" runat="server">
    
    <input type="text" id="Dtname" />
    </FORM>
    </BODY>
    </HTML>

    Originally Posted by Jonathan8146
    I don't know .Net or C#, but to get the local date/time you don't need them, just use the JavaScript "Date"
  6. #4
  7. Cunning Linguist
    ASP High Scholar (3500 - 3999 posts)

    Join Date
    Mar 2005
    Location
    I used to live at home, now I stay at the house
    Posts
    3,580
    Rep Power
    434
    Support requests via PM will be ignored!
    Route of Queue | The General FAQ Thread | HOW TO POST A QUESTION

    Perfectly Impossible - is the eagerly awaited debut release from Jayne Sarah - please buy it - it's really good!

  8. #5
  9. No Profile Picture
    Contributing User
    ASP Skiller (1500 - 1999 posts)

    Join Date
    Mar 2005
    Posts
    1,895
    Rep Power
    310
    Originally Posted by ChiefWigs1982
    The 12 hour clock is saying it is am when it is now pm where I am.
  10. #6
  11. Moderator From Beyond
    ASP Mastermind (5000+ posts)

    Join Date
    Sep 2004
    Location
    Israel
    Posts
    31,135
    Rep Power
    2926
    Originally Posted by Jonathan8146
    The 12 hour clock is saying it is am when it is now pm where I am.
    working fine for me.
  12. #7
  13. No Profile Picture
    Contributing User
    ASP Skiller (1500 - 1999 posts)

    Join Date
    Mar 2005
    Posts
    1,895
    Rep Power
    310
    Originally Posted by Shadow Wizard
    working fine for me.
    It was 12:08, maybe around noon it gets confused

Similar Threads

  1. Sql Order By Date / Time
    By cleeper in forum ASP Development
    Replies: 2
    Last Post: June 22nd, 2006, 11:37 AM
  2. Formatting Date & Time in vbScript
    By shade_v2 in forum ASP Development
    Replies: 11
    Last Post: May 21st, 2006, 02:03 AM
  3. ASP Keeps telling me isnull is false??
    By olger901 in forum ASP Development
    Replies: 48
    Last Post: April 28th, 2006, 03:09 PM
  4. Inserting Date & Time
    By Gainzim in forum Microsoft Access Help
    Replies: 2
    Last Post: October 14th, 2004, 08:17 AM
  5. Date and Time
    By Beda in forum ASP Development
    Replies: 1
    Last Post: January 24th, 2004, 08:04 AM

IMN logo majestic logo threadwatch logo seochat tools logo