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 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Dec 2013
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Formatting last modified date

    Hi everyone,

    Allow me a quick introduction. I'm not normally a webdesigner, except as a hobby, and am self-taught. However, my employer asked me to design a new website for the company. While generally, there aren't that many problems, there is one page where he intends to post news to visitors. I would like to add a snippet of code that will display the date the page was last modified. However, the code I'm using seems to never display the date in the correct format.

    Here is an example of how it is displayed:

    Laatste wijziging: 20/12/113

    (In Dutch: "Last modified: 20/12/113")

    I would like for it to be displayed in this format: dd/mm/yyyy

    I have no idea how to change the 1 to be "20". Google isn't helping much.
    The code I'm using is this:

    <script>
    function lastModified() {
    var modiDate=new Date(document.lastModified)
    var showAs=modiDate.getDate()+"/" + (modiDate.getMonth()+1)
    showAs+="/"+modiDate.getYear()
    return showAs }
    document.write ("<b>Laatste wijziging: ");
    document.write (lastModified() + "</b>");
    </script>



    Can someone give me some advice how I can make it display correctly?

    Thank you in advance!

  • #2
    Senior Coder jmrker's Avatar
    Join Date
    Aug 2006
    Location
    FL
    Posts
    3,075
    Thanks
    38
    Thanked 498 Times in 492 Posts
    Change the
    modiDate.getYear();

    to:
    .modiDate.getFullYear();

  • Users who have thanked jmrker for this post:

    Elysia (12-20-2013)

  • #3
    New to the CF scene
    Join Date
    Dec 2013
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts
    That worked. Thank you so much for your swift reply!!

  • #4
    Senior Coder jmrker's Avatar
    Join Date
    Aug 2006
    Location
    FL
    Posts
    3,075
    Thanks
    38
    Thanked 498 Times in 492 Posts
    You're most welcome.
    Happy to help.
    Good Luck!


    BTW: The 113 as significance in that it is 113 years from 1900.
    This was the start year used in the last millennium.
    Adding 113 to 1900 give you 2013 as the current year.


  •  

    Posting Permissions

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