Results 1 to 9 of 9

Thread: How to insert automatic date in a website

  1. #1
    Join Date
    May 2009
    Posts
    60

    How to insert automatic date in a website

    I am making a small website for my project work. I have done almost everything like the body, images, etc. Now I want codes to insert a automatic date in the website. Like the visitor views the web page on the internet he must be able to see the current date. Send me some codes to add a date in the web page.

  2. #2
    Join Date
    Apr 2008
    Posts
    1,948

    Re: How to insert automatic date in a website

    The below is small script of java codes to add a date in the web page. You can edit it as per your need. By adding this into your website you will get an date listed in your website and it will change everyday.
    HTML Code:
    <script language="JavaScript" type="text/JavaScript">
    var updMonths = ["1","2","3","4","5","6","7","8","9","10","11","12"];
    var updDate = new Date(document.lastModified);
    var updTxt = updDate.getDate() + '/'+updMonths[updDate.getMonth()]+'/'+updDate.getFullYear();
    document.write(updTxt);
    </script><noscript>Script for automatisk dato</noscript>

  3. #3
    Join Date
    May 2008
    Posts
    2,012

    Re: How to insert automatic date in a website

    Below is my basic workout for your date issue. Copy the below codes and paste it in the place where you want to see the date. After that save your page and reload it. Check out weather it need some editing or not.
    PHP Code:
    <script>
    var 
    mydate=new Date() 
    var 
    year=mydate.getYear() 
    if (
    year 1000year+=1900 
    var day=mydate.getDay() 
    var 
    month=mydate.getMonth() 
    var 
    daym=mydate.getDate() 
    if (
    daym<10daym="0"+daym 
    var dayarray=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"
    var 
    montharray=new Array("January","February","March","April","May","June","July","August","September","October","November","December"
    document.write(""+montharray[month]+" "+daym+", "+year+""
    </
    script

  4. #4
    Join Date
    Apr 2008
    Posts
    2,005

    Re: How to insert automatic date in a website

    As you are just using a website for a project work here it is a simple one line code to insert a date in the web page. copy paste the code in the website html script. And just insert this and very important in your properties make sure .php is selected instead of html.
    PHP Code:
      <?
    echo date('l, F j, Y');
    ?>

  5. #5
    Join Date
    Oct 2009
    Posts
    1

    Re: How to insert automatic date in a website

    Im extremely new to all this (html, css and js) and was wondering If I wanted to put the date to be displayed somewhere on my website how can i display it in a txt box on my page, rather than only be displayed at the top of my page at current.
    Im trying to add this code, (well not this exact code but something very similar) to my html/css webpage.

    Thank you so much in advance,
    -Max

    Quote Originally Posted by Katty View Post
    Below is my basic workout for your date issue. Copy the below codes and paste it in the place where you want to see the date. After that save your page and reload it. Check out weather it need some editing or not.
    PHP Code:
    <script>
    var 
    mydate=new Date() 
    var 
    year=mydate.getYear() 
    if (
    year 1000year+=1900 
    var day=mydate.getDay() 
    var 
    month=mydate.getMonth() 
    var 
    daym=mydate.getDate() 
    if (
    daym<10daym="0"+daym 
    var dayarray=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"
    var 
    montharray=new Array("January","February","March","April","May","June","July","August","September","October","November","December"
    document.write(""+montharray[month]+" "+daym+", "+year+""
    </
    script

  6. #6
    Join Date
    Jan 2008
    Posts
    1,521

    Re: How to insert automatic date in a website

    You can use the JavaScript date functions and the document.lastModified properties to get the date and print it out. If you want to put in the full word for "Mon" or "Jan", you just need to change the wording in the script.

  7. #7
    Join Date
    Feb 2011
    Posts
    1

    Re: How to insert automatic date in a website

    Hi,

    I used the code Katty posted (which is really useful, thx) but now I'm trying to figure out how to stylize the text (bold, underline, italics etc)... could anyone help me out?

  8. #8
    Join Date
    Feb 2011
    Posts
    1

    smile Re: How to insert automatic date in a website

    Yes just paste before the script example <font size="6" face="Katy Berry" color="gray">

  9. #9
    Join Date
    May 2012
    Posts
    2

    Re: How to insert automatic date in a website

    Quote Originally Posted by Katty View Post
    Below is my basic workout for your date issue. Copy the below codes and paste it in the place where you want to see the date. After that save your page and reload it. Check out weather it need some editing or not.
    PHP Code:
    <script>
    var 
    mydate=new Date() 
    var 
    year=mydate.getYear() 
    if (
    year 1000year+=1900 
    var day=mydate.getDay() 
    var 
    month=mydate.getMonth() 
    var 
    daym=mydate.getDate() 
    if (
    daym<10daym="0"+daym 
    var dayarray=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"
    var 
    montharray=new Array("January","February","March","April","May","June","July","August","September","October","November","December"
    document.write(""+montharray[month]+" "+daym+", "+year+""
    </
    script

    Thank you very much

Similar Threads

  1. Which is the best way to insert video on my website?
    By Bontu in forum Software Development
    Replies: 4
    Last Post: 08-06-2011, 08:14 AM
  2. How to insert last date in excel 2010
    By Calum in forum Windows Software
    Replies: 5
    Last Post: 18-02-2010, 12:07 AM
  3. Insert date format in SQL via ASP
    By Bansi_WADIA in forum Software Development
    Replies: 4
    Last Post: 04-12-2009, 10:56 PM
  4. How to Insert Google Map on Website
    By Gomeler in forum Tips & Tweaks
    Replies: 3
    Last Post: 21-08-2009, 12:50 PM
  5. Script insert date in the name of my file
    By Viensterrr in forum Software Development
    Replies: 4
    Last Post: 31-10-2008, 07:18 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,711,663,513.70771 seconds with 17 queries