Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Apr 2007
    Posts
    60
    Thanks
    3
    Thanked 0 Times in 0 Posts

    How to remove time from auto date & time showing script

    This is auto date&time shower. I want to remove time from the script below, and also show date without day names, I want to show just 8-19-2008. What code should I remove or add?


    <html>
    <head>
    <title>Last Modified</title>
    <script type="text/javascript">
    function getLastMod(){
    var myFrm = document.getElementById('myIframe');
    var lastModif = new Date(myFrm.contentWindow.document.lastModified);
    document.getElementById('LastModified').innerHTML = "Prices correct as at: " + lastModif.toLocaleString();
    }
    </script>
    </head>
    <body>
    <span id="LastModified"></span>

    <iframe id="myIframe" onload="getLastMod()" src="prices.txt" style="display:none;">
    </iframe>

    </body>
    </html>
    Last edited by tunayx; 08-18-2008 at 11:05 PM.

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,079
    Thanks
    203
    Thanked 2,542 Times in 2,520 Posts
    Code:
    <script type="text/javascript">
    
    function getLastMod() {
    var myFrm = document.getElementById('myIframe');
    var lm = new Date(myFrm.contentWindow.document.lastModified);
    var dt = lm.getDate();
    var mm = lm.getMonth() + 1;
    var yy = lm.getFullYear();
    var lmDate = mm + "-" + dt + "-" + yy;
    document.getElementById('LastModified').innerHTML = "Prices correct as at: " + lmDate;
    }
    
    </script>
    "Money does not bring happiness, but it does enable you to be miserable in comfort". - Philip M's personal mantra

  • Users who have thanked Philip M for this post:

    tunayx (08-19-2008)

  • #3
    New Coder
    Join Date
    Apr 2007
    Posts
    60
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Worked fine, thanks lot Philip!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •