1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

How to include the Date in my website

Discussion in 'HTML & Website Design' started by rickybuitrago, Oct 2, 2008.

  1. #1
    Hello,

    I would like to know how do I instert the date in my website in format:

    October 2, 2008

    What code should I use and where should I insert it?

    Thanks
     
    rickybuitrago, Oct 2, 2008 IP
  2. bigpapa

    bigpapa Banned

    Messages:
    273
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Its a little line of javascript, which I dont remember offhand. Try posting the ? in the Javascript forum, someone there should be able to give you the code.

    Or just google something like "javascript display date" and see what you get.
     
    bigpapa, Oct 2, 2008 IP
  3. gtseecom

    gtseecom Banned

    Messages:
    33
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Just use the javascript function of today(), and if you are coding with php, use date("Y/m/d").
     
    gtseecom, Oct 2, 2008 IP
  4. gameOn

    gameOn Member

    Messages:
    624
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    35
    #4
    in javascript you can use this to display the date

    
      var currentDate = new Date()
      var day = currentDate.getDate()
      var month = currentDate.getMonth()
      var year = currentDate.getFullYear()
      document.write("<b>" + month+ "/" + day + "/" + year + "</b>")
    
    Code (markup):
     
    gameOn, Oct 2, 2008 IP
  5. rickybuitrago

    rickybuitrago Peon

    Messages:
    170
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    So should I just paste that into my page source and the date will appear?
    Im new to this...
    thanks
     
    rickybuitrago, Oct 2, 2008 IP
  6. gameOn

    gameOn Member

    Messages:
    624
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    35
    #6
    Yes You will have to add < script > tags .. heres the full code >
    
    <script language="javascript"> var currentDate = new Date()
    var day = currentDate.getDate()
    var month = currentDate.getMonth()
    var year = currentDate.getFullYear()
    document.write("<b>" + month+ "/" + day + "/" + year + "</b>")
    </script>
    
    Code (markup):
     
    gameOn, Oct 2, 2008 IP
  7. gameOn

    gameOn Member

    Messages:
    624
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    35
    #7
    My code in above post , displays the date in digits only, if you want the name of month, day etc to appear, use this code >

    
    <script language="JavaScript">
      <!--
        var now = new Date();
        var days = new Array(
          'Sunday','Monday','Tuesday',
          'Wednesday','Thursday','Friday','Saturday');
        var months = new Array(
          'January','February','March','April','May',
          'June','July','August','September','October',
          'November','December');
        var date = ((now.getDate()<10) ? "0" : "")+ now.getDate();
        function fourdigits(number)	{
          return (number < 1000) ? number + 1900 : number;}
        today =  days[now.getDay()] + ", " +
           months[now.getMonth()] + " " +
           date + ", " +
           (fourdigits(now.getYear()));
         document.write(today);
      //-->
    </script>
    
    
    Code (markup):
    Hope this helps :)
     
    gameOn, Oct 2, 2008 IP
  8. rickybuitrago

    rickybuitrago Peon

    Messages:
    170
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    thanks man!
     
    rickybuitrago, Oct 2, 2008 IP
  9. Gremelin

    Gremelin Peon

    Messages:
    18
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    I like the PHP route myself:
    <?php echo(date("Y/m/d")); ?>
    Code (markup):
    However, it'd assume you'd be embedding it on a page which is being run through PHP (such as .php or the like)
     
    Gremelin, Oct 3, 2008 IP
  10. jcdelascasas

    jcdelascasas Greenhorn

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    21
    #10
    I would like to know how to add an ZERO "0" for months with one digit

    ---

    <script language="javascript"> var currentDate = new Date()
    var day = currentDate.getDate()
    var month = currentDate.getMonth()
    var year = currentDate.getFullYear()
    document.write("<b>" + month+ "/" + day + "/" + year + "</b>")
    </script>

    Can I add the time in the same simple form? Thank you!
     
    jcdelascasas, Jun 29, 2015 IP